拐角1

    科技2025-11-03  9

    输入5,输出: 1 1 1 1 1 1 2 2 2 2 1 2 3 3 3 1 2 3 3 4 1 2 3 4 5

    是真么做到的呢?请看以下操作:

    #include<bits/stdc++.h> using namespace std; int main() { int n,a,b; cin>>n; for(int i=1;i<=n;i++) { a=1; for(int f=1;f<i;f++) { cout<<setw(3)<<a; a++; } for(int j=i;j<=n;j++) cout<<setw(3)<<a; cout<<endl; } return 0; }
    Processed: 0.010, SQL: 8