1 solutions
-
0
C++ :
#include<iostream> #include<iomanip> using namespace std; int main() {int a[21][21]; int n,k=1; cin>>n; for (int i=1; i<=n; i++) for (int j=i,x=1; x<=n-i+1; j++) a[j][x++]=k++; for (int i=1; i<=n; i++) { for (int j=1; j<=i; j++) cout<<setw(4)<<a[i][j]; cout<<endl; } return 0; }Python :
# coding=utf-8 n=int(input()) i=n L=[1] print("% 4d" % 1) while i>1: L2=[i+1 for i in L] j=L[0]+i L.clear() L.append(j) L.extend(L2) for a in L: print("% 4d" % a,end='') print() i-=1
- 1
Information
- ID
- 17349
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By