10-03-2003, 08:26 PM | #8 (permalink) |
Tilted Cat Head
Administrator
Location: Manhattan, NY
|
i did this in my second year in HS. Had to write,"I will not make chin music in class." 100 times... i convinced the teacher that i had actually typed it 100 times, since I had a diasy wheel printer.
After that.... everyone started doing it. I had started a trend, and he wasn't all that happy with it. He then only started to collect hand written only.
__________________
I don't care if you are black, white, purple, green, Chinese, Japanese, Korean, hippie, cop, bum, admin, user, English, Irish, French, Catholic, Protestant, Jewish, Buddhist, Muslim, indian, cowboy, tall, short, fat, skinny, emo, punk, mod, rocker, straight, gay, lesbian, jock, nerd, geek, Democrat, Republican, Libertarian, Independent, driver, pedestrian, or bicyclist, either you're an asshole or you're not. |
10-03-2003, 08:34 PM | #9 (permalink) |
Crazy
Location: Anchorage, Alaska
|
I've got UNIX underpants!
no, wait, wrong strip.
__________________
"They shoot without shame In the name of a piece of dirt For a change of accent Or the colour of your shirt Better the pride that resides In a citizen of the world Than the pride that divides When a colorful rag is unfurled" -Neil Peart |
10-03-2003, 09:22 PM | #11 (permalink) |
Über-Rookie
Location: No longer, D.C
|
Cynthique, that is pretty cool.. I never had a teacher make us do the repitition on computer.. It was always hand written
nice strip I always love fox trot
__________________
"All that we can do is just survive. .All that we can do to help ourselves is stay alive." - Rush |
10-04-2003, 10:33 PM | #16 (permalink) |
Upright
|
Still nasty code. If he's only using the counter inside the for loop, should definitly be defined inside of it (assuming C++, and not C):
for ( int count = 0; count < 500; count++ ) Also, of course, the code in the strip's only going to print it 499 times. Think the teacher'll count 'em? |
10-07-2003, 08:14 PM | #22 (permalink) | |
back from sabbatical
Location: Mosptopia
|
Quote:
hey, juan, how would//should he tighten it up?
__________________
You're not fat, You're just a giant ball of love, covered in anger. |
|
10-08-2003, 03:43 PM | #23 (permalink) |
Banned
Location: shittown, CA
|
C
Code:
#include <stdio.h> int main(void) { for(int count=1; count<=500; count++){ printf("I will not throw paper airplaces in class.\n"); } return 0; } Code:
#include <iostream> void main() { for(int count=1; count<=500; count++){ cout << "I will not throw paper airplaces in class." << endl; } } Had to edit to make the includes show up. It was driving me nuts Last edited by hrdwareguy; 10-09-2003 at 04:19 AM.. |
10-08-2003, 08:28 PM | #24 (permalink) |
Junkie
Location: North Hollywood
|
juanvaldes thats invalid C, plus making everything appear on one line isn't doing anything to affect code performance, but does make it harder to read.
adding braces is arguably neater to stop running the risk of a later programmer adding more lines and it not working as one might expect , but if its a finalized app its mainly syntactic sugar, though it is something i would recommend doing and do. He may have deliberately left out the \n as that would fill the entire stdout with the phrase. and they say programmers over analyze |
10-09-2003, 03:16 AM | #26 (permalink) |
Psycho
Location: New Orleans
|
A little different but would this work as well?
Code:
#include <stdio.h> main() {int count; count=1; while (count <= 500) {++count;printf("I will not throw paper airplanes in class.\n"); } return 0; } Had to edit to make the include show up
__________________
"Everyone thinks of changing the world, but no one thinks of changing himself." -- Tolstoy Last edited by hrdwareguy; 10-09-2003 at 04:20 AM.. |
10-09-2003, 04:18 AM | #27 (permalink) | |
"Officer, I was in fear for my life"
Location: Oklahoma City
|
Quote:
|
|
10-09-2003, 08:42 PM | #29 (permalink) | |
Junkie
Location: North Hollywood
|
Quote:
int i=500; while(i--) { ..... } simple, uses a faster test which is generally implemented as a single instruction, the whole loop can be done in one instruction on a pc (ignoring the inital load), though some optimizing compilers will pick up on that the for loop and fix it. Last edited by charliex; 10-09-2003 at 08:47 PM.. |
|
10-10-2003, 01:47 PM | #31 (permalink) | |
"Officer, I was in fear for my life"
Location: Oklahoma City
|
Quote:
count number of times printed 2 1 3 2 4 3 . . . 498 497 499 498 500 499 501 End of loop </pre> So you would only end up with the sentence being printed 499 times. Last edited by hrdwareguy; 10-10-2003 at 01:52 PM.. |
|
10-10-2003, 03:04 PM | #32 (permalink) |
Junkie
Location: North Hollywood
|
hrdwareguy: nope, you are missing the key point,
2 to 501 is inclusive which equals 500 steps. example say it was i=1 to i<=5 instead of 500 so int i ; while (i<=5){ i++ }; program starts : i = 1 :loop starts is i less than or equal to 5 ? i=1, so yes, continue. i is incremented to 2 "message is printed' (1rst time) go back to top of loop is i less than or equal to 5 ? i=2 so yes, continue. i is incremented , is now 3 "message is printed' ( 2nd time) go back to top of loop is i less than or equal to 5 ? i=3 so yes, continue. i is incremented , is now 4 "message is printed' (3rd time) go back to top of loop is i less than or equal to 5 ? i=4 so yes, continue. i is incremented , is now 5 "message is printed' (4th time) go back to top of loop is i less than or equal to 5 ? i=5 so yes, continue. (not the key part here is less than *or* equal to 5 = 5 so its true, so it meets the condition. i is incremented , is now 6 "message is printed' (5th time) go to start of loop is i less than or equal to 5 ? i is now 6, so stop the loop since 6 <= 5 is false (0) 5 messages were printed. This is quite a common mistake made for junior or new programmers, its similar to people using the 5th element on an array defined as say int[5] and then using i = array[5]; which is of course the 6th element. Last edited by charliex; 10-10-2003 at 03:12 PM.. |
10-13-2003, 02:54 AM | #33 (permalink) | |
"Officer, I was in fear for my life"
Location: Oklahoma City
|
Quote:
I understand this. The original code I was referring to did not say <= 501 it said <=500. Go back and look at it if you want to. Since the original code I was referring to was therefore 2 to 500, I still stand by my statement that it will only print 499 times. |
|
10-13-2003, 11:15 AM | #34 (permalink) | |
Junkie
Location: North Hollywood
|
hrdwareguy: dear oh dear, please read over my comment
Quote:
For instance my example is 1 to 5 but it runs as 2 to 6. so when you do <=n , n ends up being + 1 i really don't know how to simplify it anymore so that you can understand it. So heres another proof (hope this posts correctly) i added my comments with a // to the actual session Code:
// show contents of file test.cpp ( i copied and pasted from hrdwareguys quote exactly as was ) [C:\4nt]type test.cpp #include <stdio.h> main() {int count; count=1; while (count <= 500) {++count;printf("I will not throw paper airplanes in class.\n"); } return 0; } // compile it [C:\4nt]cl -nologo test.cpp test.cpp // run it with a redirect into a file [C:\4nt]test >out.txt //run wc, which is a wordcounter with line count [C:\4nt]wc out.txt out.txt: Words: 4000 Lines: 500 Chars: 21000 I could post the exe if you still don't believe me, but if you go over the loop i typed it in the previous comment it will be come obvious to you (since it does seem like you didn't read it through as the comment you made indicates you didn't see where i said <=500 twice) Last edited by hrdwareguy; 10-13-2003 at 11:31 AM.. |
|
10-13-2003, 11:32 AM | #36 (permalink) |
"Officer, I was in fear for my life"
Location: Oklahoma City
|
Charliex: OK, I get it, you are correct. I was getting getting confused because I usually increment my loops at the bottom. Got one to many tests in there.
By the way, I edited your post for the sole purpose of making the <stdio.h> display correctly. Last edited by hrdwareguy; 10-13-2003 at 11:35 AM.. |
10-13-2003, 12:01 PM | #38 (permalink) |
Junkie
Location: North Hollywood
|
Code:
#include <stdio.h> main() {int count; count=1; do {++count;printf("I will not throw paper airplanes in class.\n"); }while(count <= 500); return 0; } It would still print 500 lines. Last edited by hrdwareguy; 10-13-2003 at 12:12 PM.. |
10-13-2003, 12:12 PM | #39 (permalink) | |
"Officer, I was in fear for my life"
Location: Oklahoma City
|
Quote:
|
|
10-13-2003, 12:17 PM | #40 (permalink) |
"Officer, I was in fear for my life"
Location: Oklahoma City
|
Actuall in my mind it was something like this:
Code:
#include <stdio.h> int main(void) { int count=1; while(count <=500) { ++count; //as a one time increment printf("I will not throw paper airplanes in class\n"); ++count;//as I usuall do my incrementing at the bottom } return 0; } |
Tags |
comic, foxtrot |
|
|