|
Answer» Hey everyone,
I've used this site as a resource for such a long time, but never GOT into the forum... until now. I thought a good way to get my feet wet would be to post a fun C++ problem I have enjoyed before. Hopefully it is a new problem to some of you!
Give it your best! (and don't post answers when you get them... let everyone have a fair chance)
Code: [Select]#include<iostream>
using namespace std;
int main() { int i, n = 20; for (i=0; i<n; i--) { cout << "x" << endl; } }
/* Directions: =========== Find three ways to make the above code print x 20 times (by changing only one character) */
Click http://www.blarged.com/blog/CPP_Problem.cpp to download the source file straight to your box.
Best of luck! Hopefully you do better than I did!A tip to all: The current code is an infinite LOOP. I'm on it, because I can't resist.
EDIT: Question: Does the "--" COUNT as one character? It's certainly only one operator... Quote from: Dilbert on July 10, 2007, 04:49:11 PM A tip to all: The current code is an infinite loop. I'm on it, because I can't resist.
EDIT: Question: Does the "--" count as one character? It's certainly only one operator...
no, the '--' counts as two SEPARATE characters. each KEYSTROKE is one character :-)
its tough!Nobody's playing? Well, I've found two. And I'd really like to know the one I'm missing. Has anyone found the three solutions?Odd. It won't compile for me anymore.
Permission denied ld returned 1 exit status
is all I'm getting for an error message, though. Doesn't help me find out what's wrong. Ok, found the third as soon as I woke up. Who said sleeping was a waste of time ? lol
Dilbert, everything compiled for me. Sorry I can't help (real noob at programming).
|