Created
April 16, 2017 08:16
-
-
Save shihchun/1aca915527d5b91191211390edd42f05 to your computer and use it in GitHub Desktop.
My first C++ Program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> //input/output on stream | |
#include <iomanip> //setw | |
using namespace std; //~~std::~~ | |
void star(int, int); | |
int x, start = 1; | |
int main() | |
{ | |
int i=1,k=1,z; | |
cout<<"Qing Shu Ru Yi Ge Shu Zi : "; //display message | |
cin>>x; //input message | |
z=3*x-1; //lowend,*'s quantity | |
star(start,x);//upper start 需要重置成 1 | |
//lowend | |
for(i=1;i<=x;i++) | |
{ | |
for(k=1;k<=x;k++) | |
{ | |
cout<<" "; | |
} | |
for(k=1;k<=z;k++) | |
{ | |
cout<<"*"; | |
} | |
cout<<endl; | |
} | |
} | |
void star(int sta,int final)//upper tran | |
{ | |
if(sta<=final) | |
{ | |
for (int i=1;i<=sta;i++) | |
cout<<setw(i); | |
for (int i=1;i<=sta;i++) | |
cout <<"*"; | |
for(int i=1;i<=sta;i++) | |
cout<<setw((-4)*i+5*x+2);//The width of the crown head | |
for (int i=1;i<=sta;i++) | |
cout << "*"; | |
cout << endl; | |
star(sta+1,final); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment