M
Mohammad
Dear Friends:
I started learning c/c++ 2 weeks ago and so known a little about c++
!!!
now the problem is that, I found an excercise that I couldn't solve it
in no ways !!!
The problem is that:
make this shape with 2 or 3 "for" Repetition Statement. (It means that
it is possible even if with 2 !):
**********
********
******
****
**
****
******
****
**
****
******
********
**********
I programmed one, but it isn't what I want ! but it's this:
// Assignment 1: Excercise 1: Shape
// Making a strange shape !!!
// Programmed By: Mohammad Dashti
#include <iostream>
using namespace std;
int main()
{
for (int i = 0 ; i <= 12 ; i++){
if (i<=7){
for (int j = 1 ; j <= 10-i ; j++){
if (i<=4 && j<=i) cout << " ";
else if (i<=4 && j>i) cout << "*";
if ((i==5 || i==7) && j==2) cout << " ";
else if ((i==5 || i==7) && j==3) cout << "****";
if ( i==6 && j<=2) cout << " ";
else if (i==6 && j==3) cout << "******";
}
}
if(i>=8){
for (int j = 11 ; j >= 14-i ; j--){
if (j>=i) cout << " ";
else cout << "*";
}
}
cout << endl;
}
return 0; // indicate successful termination
} // end main
You will glad me, if you send me the solution as soon as possible !
I started learning c/c++ 2 weeks ago and so known a little about c++
!!!
now the problem is that, I found an excercise that I couldn't solve it
in no ways !!!
The problem is that:
make this shape with 2 or 3 "for" Repetition Statement. (It means that
it is possible even if with 2 !):
**********
********
******
****
**
****
******
****
**
****
******
********
**********
I programmed one, but it isn't what I want ! but it's this:
// Assignment 1: Excercise 1: Shape
// Making a strange shape !!!
// Programmed By: Mohammad Dashti
#include <iostream>
using namespace std;
int main()
{
for (int i = 0 ; i <= 12 ; i++){
if (i<=7){
for (int j = 1 ; j <= 10-i ; j++){
if (i<=4 && j<=i) cout << " ";
else if (i<=4 && j>i) cout << "*";
if ((i==5 || i==7) && j==2) cout << " ";
else if ((i==5 || i==7) && j==3) cout << "****";
if ( i==6 && j<=2) cout << " ";
else if (i==6 && j==3) cout << "******";
}
}
if(i>=8){
for (int j = 11 ; j >= 14-i ; j--){
if (j>=i) cout << " ";
else cout << "*";
}
}
cout << endl;
}
return 0; // indicate successful termination
} // end main
You will glad me, if you send me the solution as soon as possible !