Hello everyone, i have another assignments that i can't deal with my ability yet.
This is the assignment :
Make a pyramid from a character where you can define it's height !
Example : 4 characters height pyramid from "x" character
X
XXX
XXXXX
6 characters height
x
xxx
xxxxx
xxxxxxx
xxxxxxxxx
xxxxxxxxxxx
then so on. I have difficulty to solve this assignment. However, this one of my attempt, please give some suggestion.
#include <iostream>
using namespace std;
int main (){
int a,z,x;
cout<<"Insert pyramid height :";cin>>a;
for (int b=a; b>=1; b--){
for (int c=1;c<=b;c++){
z=b-1;
if (c<=z){
cout<<" ";
}
for (int y=a;y>=1;y--){
for (int d=0;d<=a*2-1;d=d*2+1){
x=y+d;
if ((c>=b)&&(c<=x)){
cout<<"x";
}
}
}
}
cout<<endl;
}
return 0;
}