大哥。。。你的num是啥啊?没有初始化你怪他全是0?
by Steve_xh @ 2023-07-11 18:10:25
@[Harry_Haiyun](/user/977778)
by Steve_xh @ 2023-07-11 18:10:32
@[Steve_xh](/user/639198) num是赋值型数组啊??!
by __Harry_Haiyun__ @ 2023-07-11 18:14:16
@[Harry_Haiyun](/user/977778) num赋值反了
by 幻想繁星 @ 2023-07-11 18:23:26
@[Harry_Haiyun](/user/977778) 你在哪赋的值?我咋没看到?
by Steve_xh @ 2023-07-11 18:55:34
在输出前加一句 `cout << sum << endl;`。
`sum++;` 下面的那部分把 `=` 左右的部分对调,例如 `num[sum][0] = a;`、`num[sum][1] = b;`等等。
然后就可以快乐地通过本题了!
完整版:
```cpp
#include <bits/stdc++.h>
#define MOD 998244353
#define mod 1000000007
using namespace std;
int n,num[100005][10];
int main() {
cin >> n;
int sum = 0;
for (int a = 1; a <= 3; a++) {
for (int b = 1; b <= 3; b++) {
for (int c = 1; c <= 3; c++) {
for (int d = 1; d <= 3; d++) {
for (int e = 1; e <= 3; e++) {
for (int f = 1; f <= 3; f++) {
for (int g = 1; g <= 3; g++) {
for (int h = 1; h <= 3; h++) {
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
if (a+b+c+d+e+f+g+h+i+j == n) {
sum++;
num[sum][0] = a;
num[sum][1] = b;
num[sum][2] = c;
num[sum][3] = d;
num[sum][4] = e;
num[sum][5] = f;
num[sum][6] = g;
num[sum][7] = h;
num[sum][8] = i;
num[sum][9] = j;
}
}
}
}
}
}
}
}
}
}
}
cout << sum << endl;
for (int z = 1; z <= sum; z++) printf("%d %d %d %d %d %d %d %d %d %d\n",num[z][0],num[z][1],num[z][2],num[z][3],num[z][4],num[z][5],num[z][6],num[z][7],num[z][8],num[z][9]);
return 0;
}
```
by Ifyoung @ 2023-07-11 19:33:20
我的更长但可以过不知为啥
```
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
int main() {
int a,b,c,d,e,f,g,h,i,j,in,x=0;
cin>>in;
for (a=1;a<=3;a++) {
for (b=1;b<=3;b++) {
for (c=1;c<=3;c++) {
for (d=1;d<=3;d++) {
for (e=1;e<=3;e++) {
for (f=1;f<=3;f++) {
for (g=1;g<=3;g++) {
for(h=1;h<=3;h++) {
for (i=1;i<=3;i++) {
for (j=1;j<=3;j++) {
if (a+b+c+d+e+f+g+h+i+j==in) {
x++;
}
}
}
}
}
}
}
}
}
}
}
cout<<x<<endl;
for (a=1;a<=3;a++) {
for (b=1;b<=3;b++) {
for (c=1;c<=3;c++) {
for (d=1;d<=3;d++) {
for (e=1;e<=3;e++) {
for (f=1;f<=3;f++) {
for (g=1;g<=3;g++) {
for(h=1;h<=3;h++) {
for (i=1;i<=3;i++) {
for (j=1;j<=3;j++) {
if (a+b+c+d+e+f+g+h+i+j==in) {
cout<<a<<" ";
cout<<b<<" ";
cout<<c<<" ";
cout<<d<<" ";
cout<<e<<" ";
cout<<f<<" ";
cout<<g<<" ";
cout<<h<<" ";
cout<<i<<" ";
cout<<j<<endl;
}
}
}
}
}
}
}
}
}
}
}
}
```
by tangwulin123 @ 2023-07-12 10:41:07
while(1)
{
cout<<6;
}
by ss_yangyucheng @ 2023-08-08 11:48:30