Author Topic: My schoolwork got rejected...  (Read 16659 times)

0 Members and 1 Guest are viewing this topic.

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
My schoolwork got rejected...
« on: May 17, 2010, 04:08:13 pm »
My schoolwork got rejected because it was too complex for my teacher to grade.  I think my Axe and Asm knowledge rubbed off, making my C++ a lot more optimized.  My teacher took one look at it, shook his head, and told me that he wouldn't grade anything that complex.  For those who know C++, you make the call.

My awesome version:
Code: [Select]
#include<fstream.h>
#include<iostream.h>

void main()
{
char string[25], header[50] = "Name     \0Address  \0City     \0State    \0ZIP Code ";
ifstream file_ptr;

int offset = 0;
file_ptr.open("ADDRFILE.DAT",ios::in);
if (file_ptr)
{
do
{
file_ptr.get(string, 25);
file_ptr.ignore(80, '\n');
if (!file_ptr.eof())
cout << header + 10 * offset << ':' << string << '\n';
offset = (offset + 1) % 5;
}
while (!file_ptr.eof());


file_ptr.close();
}
else
cout << "An Error occured!\n";
}

The version I had to turn in:
Code: [Select]
#include<fstream.h>
#include<iostream.h>

void main()
{
char name[25], address[25], city[25], state[25], zip[25];
ifstream file_ptr;

file_ptr.open("ADDRFILE.DAT",ios::in);
if (file_ptr)
{
do
{
file_ptr.get(name, 25);
file_ptr.ignore(80, '\n');
file_ptr.get(address, 25);
file_ptr.ignore(80, '\n');
file_ptr.get(city, 25);
file_ptr.ignore(80, '\n');
file_ptr.get(state, 25);
file_ptr.ignore(80, '\n');
file_ptr.get(zip, 25);
file_ptr.ignore(80, '\n');
if (!file_ptr.eof())
{
cout << "Name: " << name << '\n';
cout << "Address: " << address << '\n';
cout << "City: " << city << '\n';
cout << "State: " << state << '\n';
cout << "ZIP Code: " << zip << '\n';
}
}
while (!file_ptr.eof());


file_ptr.close();
}
else
cout << "An Error occured!\n";
}

Is there a version that's even more optimized?  Feel free to rewrite it if you want... ;D
« Last Edit: May 17, 2010, 04:16:38 pm by ztrumpet »

Offline Galandros

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1140
  • Rating: +42/-10
    • View Profile
Re: My schoolwork got rejected...
« Reply #1 on: May 17, 2010, 04:52:38 pm »
Interesting. Assembly power, ftw.

The first code looks much better (smaller, less repetitive, flexible to changes) to me even if I don't know what those C++ functions are doing exactly.
Hobbing in calculator projects.

Offline Silver Shadow

  • Beta Tester
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +27/-7
    • View Profile
Re: My schoolwork got rejected...
« Reply #2 on: May 17, 2010, 05:21:37 pm »
Sometimes teachers are really stupid...
Former Coder of Tomorrow


Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: My schoolwork got rejected...
« Reply #3 on: May 17, 2010, 05:44:24 pm »
Wow, that is really annoying when teachers do that :( Sorry you had to downgrade your project.
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: My schoolwork got rejected...
« Reply #4 on: May 17, 2010, 05:45:41 pm »
Sorry you had to downgrade your project.
Nah, it's fine, as it only took me 10 more minutes. ;D

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Re: My schoolwork got rejected...
« Reply #5 on: May 17, 2010, 05:53:01 pm »
Sigh... If the teacher can't understand something you can, he ought to learn how your code works...
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: My schoolwork got rejected...
« Reply #6 on: May 17, 2010, 05:55:22 pm »
Sigh... If the teacher can't understand something you can, he ought to learn how your code works...

I agree with that. Or that you should teach the class for the day and get the money he would've made :P

Haha well its still harder to think in unoptimized thoughts once you are good at not doing it :P
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: My schoolwork got rejected...
« Reply #7 on: May 17, 2010, 06:19:21 pm »
he should have given you full marks if it surpassed his level...after all that is then past the level of the course isn't it?
/e

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: My schoolwork got rejected...
« Reply #8 on: May 17, 2010, 07:00:51 pm »
Lol, that is both a win on your part and a fail on his part :P he should have given you full marks, or maybe *tried* to decipher it! ;D

Offline simplethinker

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 695
  • Rating: +16/-5
  • snjwffl
    • View Profile
Re: My schoolwork got rejected...
« Reply #9 on: May 17, 2010, 09:09:36 pm »
lol epic fail on your teacher's part :D

The disturbing thing is... what part was too complex for him?  The only real differences are the two lines
Code: [Select]
cout << header + 10 * offset << ':' << string << '\n';
offset = (offset + 1) % 5;
The first is fairly straight forward (display "{something}: {what you retrieved}"), and the second is just making "offset" go 0-1-2-3-4-0-1-2-3-4...

[edit] Now that I think about it, for my mathematical software survey ("SoftSurv" for short :)) final project my code had a lot of tricks like that.  I wonder if that's why I got an A in the class (my code was completel crap lol)
« Last Edit: May 17, 2010, 09:11:47 pm by simplethinker »
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the Internet, we know this is not true." -- Professor Robert Silensky



Chip's Challenge: ħ%

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: My schoolwork got rejected...
« Reply #10 on: May 17, 2010, 09:27:32 pm »
That code isn't hard to follow at all, and its not very complex.  But I have a feeling what your teacher is complaining about is that you made it very "C style" instead of "C++ style".  They want to train you to stick with the C++ commands and not do those efficient workarounds becasue eventually you're going to be dealing with abstract objects and your code will no longer be portable when instead of strings you have classes and instead of characters you have child objects.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: My schoolwork got rejected...
« Reply #11 on: May 17, 2010, 10:06:43 pm »
That code isn't hard to follow at all, and its not very complex.  But I have a feeling what your teacher is complaining about is that you made it very "C style" instead of "C++ style".  They want to train you to stick with the C++ commands and not do those efficient workarounds becasue eventually you're going to be dealing with abstract objects and your code will no longer be portable when instead of strings you have classes and instead of characters you have child objects.
Okay, that's probably why he did it.  He likes to have us program certain exercises in a certain way because it'll help us later on.  Thanks for the info! :D

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: My schoolwork got rejected...
« Reply #12 on: May 17, 2010, 10:49:17 pm »
Wow that was retarded from the teacher, but again maybe Quibigo has a point. Still, I would hate if I worked hard on a school project and it got rejected because it surpasses the teacher requirements way too much.

In my case, the worst I had happen is that the teacher and other students couldn't help me fixing bugs in my last project before graduation (The Reign of Legends 0). It was too advanced for him so I was pretty much on my own x.x

Offline Geekboy1011

  • The Oneironaut
  • Donator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2031
  • Rating: +119/-2
  • Dream that Awakening dream
    • View Profile
Re: My schoolwork got rejected...
« Reply #13 on: May 17, 2010, 11:16:16 pm »
nice ztrumpet thats a;ways interesting to see a student do better than a teacher
and my teach is the same way i can do ti this way she wants it that way oh well xD

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: My schoolwork got rejected...
« Reply #14 on: May 18, 2010, 08:28:03 am »
I don't have much experience with C++, but Quigbo does raise a very good point. Nice insight there! You should also remember that many teachers just know how to grade things based on how the course is laid out, IE they only have knowledge of/ teach what is outlined in the course, and may not have (much) experience on the subject outside of that, especially on the high-school level. It's unfortunate, but that is the way our public education system is in the U.S.