Originally posted by whodgson
Commonly the terminal moves the output cursor to the next column multiple of 8.
// exercise 2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <sstream>
#include <iomanip>
using std::cout; using std::stringstream;
using std::string; using std::setw;
int main()
{
int i=0, max, width1, width2;
max=100;
{stringstream store;
store<<max;
string size;
store>>size;
width1=size.length();
i=max*max;
store<<i;
store>>size;
width2=(size.length());
}
for(i=0;i<=max;i++)
cout<<setw(width1)<<i<<setw(width2)<<i*i<<"\n";
system("PAUSE");
return 0;
}
Leave a comment: