8 条题解
-
2lichengjun LV 10 @ 2023-4-10 21:39:39
#include<iostream> using namespace std; int a[35][35],n; int main(){ cin>>n; a[1][1]=1; for(int i=2;i<=n;i++) for(int j=1;j<=n;j++)a[i][j]=a[i-1][j]+a[i-1][j-1]; for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++)cout<<a[i][j]<<" "; cout<<endl; } return 0; }
-
12023-10-11 18:45:19@
#include<bits/stdc++.h> using namespace std; int n,m,sum=0; int main(){ cin>>n; int a[n+2][n+2]; memset(a,0,sizeof(a)); a[1][1]=1; for(int i=2;i<=n;i++){ for(int j=1;j<=n;j++){ a[i][j]=a[i-1][j]+a[i-1][j-1]; } } for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++)cout<<a[i][j]<<" "; cout<<endl; } return 0; }
-
12023-4-9 18:42:40@
#include<iostream> using namespace std; int main() { int n,a[213][213],i,j; cin>>n; for(i=0;i<=n-1;i++) { for(j=0;j<=i;j++) { if(j==0||j==i) a[i][j]=1; else a[i][j]=a[i-1][j-1]+a[i-1][j]; cout<<a[i][j]<<" "; } cout<<"\n"; } return 0; }
-
02024-11-17 18:53:47@
#include<stdio.h> #include<iostream> using namespace std; int a[1005][1005]; int main(){ int n; cin>>n; a[1][1]=a[2][1]=a[2][2]=1; for(int i=3;i<=n;i++){ a[i][1]=a[i][i]=1; for(int j=2;j<i;j++){ a[i][j]=a[i=1][j=1]+a[i=1][j]; } } for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ cout<<a[i][j]<<" "; } cout<<endl; } }
-
02024-10-25 18:26:17@
6
#include <bits/stdc++.h> using namespace std; int a[40][40]; int n; int main(){ cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(j==0||j==i){ a[i][j]=1; } else{ a[i][j]=a[i-1][j-1]+a[i-1][j]; } } } for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ cout<<a[i][j]<<" "; } cout<<endl; } return 0; }
-
02024-3-3 9:27:35@
#include <iostream> using namespace std; int a[40][40],n; int main() { cin>>n; a[0][1]=1; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { a[i][j]=a[i-1][j]+a[i-1][j-1]; cout<<a[i][j]<<" "; } cout<<endl; }
return 0;
}
-
-42022-10-21 22:20:29@
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
#define LL long long
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
using namespace std;
int main(){
int n,a[213][213],i,j;
cin>>n;
for(i=0;i<=n-1;i++)
{
for(j=0;j<=i;j++)
{
if(j0||ji) a[i][j]=1;
else a[i][j]=a[i-1][j-1]+a[i-1][j];
cout<<a[i][j]<<" ";
}
cout<<"\n";
}
return 0;
} -
-52023-2-26 15:10:17@
#include<bits/stdc++.h>
using namespace std;
int a[40][40];
int main(){
a[1][1] = 1;
int n;
cin>>n;
for(int i = 2; i <= n; i++ ){
for(int j = 1; j <= i; j++ ){
a[i][j] = a[i-1][j]+a[i-1][j-1];
}
}
for(int i = 1; i <= n;i++ ){
for(int j = 1; j <= i;j++ ){
cout<<a[i][j]<<" ";
}
cout<<endl;
}
}
- 1
信息
- ID
- 1078
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 473
- 已通过
- 197
- 上传者