Skip to content

Instantly share code, notes, and snippets.

@mutaku
Created December 3, 2012 16:43
Show Gist options
  • Save mutaku/4196194 to your computer and use it in GitHub Desktop.
Save mutaku/4196194 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
/* Practicing examples from http://web.cse.msu.edu/~cse231/python2Cpp.html
and http://code.google.com/edu/languages/cpp/basics/getting-started.html */
int reader(string line)
{
cout << line << endl;
return 0;
}
int printer(int i, int j)
{
for (int x = 0; x < i; x++)
{
for (int y = 0; y < j; y++)
cout << setw(15) << "Hello, World!";
cout << endl;
}
return 0;
}
int main(){
cout << "Hello, World!" << endl;
int A[2] = {2,3};
int B[2];
for (int i = 0; i < 2; i++)
B[i] = A[i];
B[0]= 100;
for (int i = 0; i < 2; i++)
cout << "A,B: " << A[i] << ", " << B[i] << endl;
for (int x = 0; x < 6; x = x+2)
cout << x << endl;
ifstream InStream;
string line;
InStream.open("hello.cpp");
getline(InStream, line);
while (!InStream.eof())
{
//cout << line << endl;
reader(line);
getline(InStream, line);
}
printer(3, 3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment