Re: Exercise from C++ How to program Cyber classroom 4th ed.
From: loupceuxl (loupceuxl_at_hotmail.com)
Date: 01/31/05
- Next message: Jigar Mehta: "Re: how to start with templates ??"
- Previous message: Howard Hinnant: "Re: Effective STL Item 4 (size() vs. empty())"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 30 Jan 2005 23:52:43 -0500
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int x,
counter = 1;
cout << "Please input an integer between 1 and 20 to form the sides of a
square: " << endl;
cin >> x;
while ( counter <= (x * x) ) {
if ( ((counter % x) == 1) || (counter < x) || (counter > x * x - x) )
{
cout << "*";
}
else if ( (counter % x) == 0 ) {
cout << "*\n";
}
else if ( ((counter % x) > 1) && ((counter % x) < x) ) {
cout << " ";
}
++counter;
}
cout << endl;
return 0;
}
- Next message: Jigar Mehta: "Re: how to start with templates ??"
- Previous message: Howard Hinnant: "Re: Effective STL Item 4 (size() vs. empty())"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]