Simple Yet Complex?
I need to make a program that displays '*' Characters. I'm only supposed to use nested loops and no text messages to print the asterisks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include<iostream>
#include<fstream>
#include<math.h>
#include<iomanip>
using namespace std;
int main ()
{
int LCV = 1;
char Nothing = ' ';
int Something = 5;
for (LCV = 1; LCV < 4; LCV++)
{
cout<<Nothing<<setw(6)<<showpoint<<setprecision(6)<<setfill('*');
cout<<Nothing<<endl;
Something -= 2;
if (Something == 3)
{
Nothing = ' ';
}
if (Something == 1)
{
Nothing = ' ';
}
}
return 0;
}
|
I need it to display:
/*
*****
***
*
*/
/*
*****
*****
*****
--------------------------------
Process exited after 0.2104 seconds with return value 0
Press any key to continue . . .
*/
|
Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include<iostream>
using namespace std;
int main ()
{
for (int i = 5; i > 0; i -= 2)
{
for(int j = 0; j < i; j++)
cout << '*';
cout << endl;
}
return 0;
}
|
Topic archived. No new replies allowed.