感覺上...這好像是作業....不過還是幫你改了~
複製程式
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int q ;
cin>>q;
int r = 0;
for(int i = q, j =0 ; i > 0; i--, j++)
{
r = 0;
string s1 = "";
for( int k = 1; k < i; k++)
{
s1 += " ";
}
cout << s1 + "*";
r++;
for(int m = 0; m < j; m++)
{
r+=2;
cout << " ";
cout << "*";
}
cout << "" << endl;
}
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < (r / 2); j ++)
{
cout << " ";
}
cout << "*";
cout << "" << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
這是用dev-c++ 編譯過沒問題..有問題再問...
希望不是作業題