搞了n次都是格式错误??
程序代码:
#include"iostream" using namespace std; int main() { int i,num,j,m=0; char c; while(scanf("%c%d",&c,&num)!=EOF) { if(c=='@')exit(0); if(m++)cout<<endl; for(i=1;i<num;i++) { for(j=1;j<=num-i;j++) //循环结束后j=num-i+1 cout<<" "; cout<<c; for(j+=1;j<=num+i-2;j++) cout<<" "; if(i!=1) cout<<c; cout<<endl; } for(j=1;j<=2*i-1;j++) cout<<c; cout<<endl; } return 0; }