I'm learning C++!

I thought it’d be nice to learn C++ alongside Python, so I submitted the same algorithm for SPOJ project code TEST in C++:

#include <iostream>
#include <cstdlib>

using namespace std;

int main () {
	int num;
	num = 0;
	while (num != 42) {
		cin >> num;
		if (num == 42) {
			return 0;
			}
		cout << num << '\n';
		}
	return 0;
	}

w00t yeah. Intrepid comes with a newer version of libtools than KDevelop currently has, so it wouldn’t compile correctly at first. I found this useful ubuntuforums.org post to help me out.

btw, for the purposes of this post, I indented the code above using lots of &nbsp;, which is really annoying. Does anyone have a better solution?

Advertisements
    • jd
    • February 20th, 2009

    I guess if you use the pre tag, you can indent with normal spaces, and don’t need line breaks.

    • undefined117
    • February 20th, 2009

    Ah that works almost perfectly (I’ll have to enlarge the font, though). Thanks, jd!

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: