社区讨论
为什么 int[int] 会报错
P2089烤鸡参与者 9已保存回复 13
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 13 条
- 当前快照
- 1 份
- 快照标识符
- @lo7p8wc3
- 此快照首次捕获于
- 2023/10/27 05:31 2 年前
- 此快照最后确认于
- 2023/10/27 05:31 2 年前
RT。
CPP#include<iostream>
#include<iomanip>
using namespace std;
int main(){
int n,cnt=0,a[100],b[100],c[100],d[100],e[100],f[100],g[100],h[100],i[100],j[100];
cin>>n;
if(n<10||n>30){
cout<<0;
return 0;
}
for(int a=1;a<4;a++){
for(int b=1;b<4;b++){
for(int c=1;c<4;c++){
for(int d=1;d<4;d++){
for(int e=1;e<4;e++){
for(int f=1;f<4;f++){
for(int g=1;g<4;g++){
for(int h=1;h<4;h++){
for(int i=1;i<4;i++){
for(int j=1;j<4;j++){//暴力枚举
if(a+b+c+d+e+f+g+h+i+j==n){//判断
a[cnt]=a;
b[cnt]=b;
c[cnt]=c;
d[cnt]=d;
e[cnt]=e;
f[cnt]=f;
g[cnt]=g;
h[cnt]=h;
i[cnt]=i;
j[cnt]=j;//存储
cnt++;
}
}
}
}
}
}
}
}
}
}
}
cout<<cnt<<endl;
for(int z=0;z<cnt;z++)cout<<a[z]<<" "<<b[z]<<" "<<c[z]<<" "<<d[z]<<" "<<e[z]<<" "<<f[z]<<" "<<g[z]<<" "<<h[z]<<" "<<i[z]<<" "<<j<<endl;//输出
return 0;
}
回复
共 13 条回复,欢迎继续交流。
正在加载回复...