7 条题解
-
0
#include <iostream> #include <iomanip> using namespace std; short cnt = 1,a[31][31],n,mcnt; int main() { cin >> n; if (n == 1) { cout << 1; return 0; } for(int i = 1;i <= n;i++) mcnt += i; a[n - 1][0] = 1; short x = n - 2,y = 0,xx = n - 3; while(cnt <= mcnt) { a[x][y] = ++cnt; if (x == n - 1) { x = xx; y = 0; xx--; } else { x++; y++; } } for (int i = 0;i < n;i++) { for (int j = 0;j < i + 1;j++) cout << setw(4) << a[i][j]; cout << endl; } return 0; } -
0
谁说的@何辰恩
#include<bits/stdc++.h> using namespace std; const int N=3e1+5,INF=0x3f3f3f3f; int n,a[N][N],h=1,l,cnt; int main() { cin>>n; for(int i=1;i<=n;i++){ l = i; while(l>0){ a[h][l] = ++cnt; h++; l--; } h = 1; } for(int i=n;i>=1;i--){ for(int j=1;j<=n+1-i;j++)cout<<setw(4)<<a[j][i]<<" "; cout<<endl; } } -
-1
#include <queue> #include <math.h> #include <stack> #include <vector> #include <stdio.h> #include <iostream> #include <vector> #include <iomanip> #include <string.h> #include<cstring> #include <algorithm> #define LL long long const int N=1e2+10; const int INF = 0x3f3f3f3f; using namespace std; int n,i,j,a[N][N]; int main(int argc,char const*argv[]) { cin>>n; int s=1; int k=n; i=n-1; j=0; int s1=0,s2; while(k){ k--; while(i<=n-1){ a[i][j]=s; s1=i; i++,j++; s++; } i=k; i--; j=0; } for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(a[i][j]!=0){ printf("%4d",a[i][j]); } } printf("\n"); } return 0; }其他题解好像都在Ctrl大佬的呀(除某V10dalao)bushi我
-
-3
#include<stdio.h> int main(int argc,char const*argv[]) { int n,i,j,a[100][100]={0}; scanf("%d",&n); int s=1; int k=n; i=n-1; j=0; int s1=0,s2; while(k) { k--; while(i<=n-1) { a[i][j]=s; s1=i; i++,j++; s++; } i=k; i--;j=0; } for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i][j]!=0) printf("%4d",a[i][j]); } printf("\n"); } } -
-3
#include<stdio.h> int main(int argc,char const*argv[]) { int n,i,j,a[100][100]={0}; scanf("%d",&n); int s=1; int k=n; i=n-1; j=0; int s1=0,s2; while(k) { k--; while(i<=n-1) { a[i][j]=s; s1=i; i++,j++; s++; } i=k; i--;j=0; } for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[i][j]!=0) printf("%4d",a[i][j]); } printf("\n"); } }
- 1
信息
- ID
- 1075
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- 递交数
- 408
- 已通过
- 129
- 上传者