#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,k=0; cin>>a; for(int i=1;i<=a;i++) { for(int j=1;j<=i;j++) { k++; if(k>=10){ cout<<" "<<k; } else cout<<" "<<k; } cout<<endl; } return 0;
}
谢谢
输出数字错了, 不能用空格, 应该用 cout << setw(4) << k 或者 printf("%4d", k);
共 2 条回复
谢谢
输出数字错了, 不能用空格, 应该用 cout << setw(4) << k 或者 printf("%4d", k);