全是WA,求助大佬

P2550 [AHOI2001] 彩票摇奖

@[Haidde](/user/1215070) 输出不需要取地址符&
by GoodLuckCat @ 2024-02-06 16:49:45


还有,你输出的那几个换行是干什么的???
by GoodLuckCat @ 2024-02-06 16:50:00


@[Haidde](/user/1215070) printf不需要加&
by PengDave @ 2024-02-06 16:50:17


还有,你输入后输出换行符干啥
by PengDave @ 2024-02-06 16:51:33


格式错误已经改过了,AC了,谢谢各位大佬
by Haidde @ 2024-02-06 17:36:59


@[Haidde](/user/1215070) 你没有发现两个帖子有亿点点相似吗
by GoodLuckCat @ 2024-02-06 20:21:27


``` #include<iostream> #include<cmath> #include<cstdio> using namespace std; int main() { int n, a[7] = { 0 }, b[1000][7] = { 0 }, cent[1000] = { 0 }; cin >> n; for (int i = 0; i < 7; i++) cin >> a[i]; for (int i = 0; i < n; i++) { for (int j = 0; j < 7; j++) { cin >> b[i][j]; for (int* p = &a[0], q = 0; q < 7; q++, p++) if (b[i][j] == *p) cent[i]++;//每张中奖个数; } } int p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0, po = 0; for (int i = 0; i < n; i++) { if (cent[i] != 0) switch (cent[i]) { case 1:p6++; break; case 2:p5++; break; case 3:p4++; break; case 4:p3++; break; case 5:p2++; break; case 6:p1++; break; case 7:po++; } } cout << po << " " << p1 << " " << p2 << " " << p3 << " " << p4 << " " << p5 << " " << p6 << endl; return 0; } ``` @[Haidde](/user/1215070) 第二个循环那里用指针会好一点,因为不会改变原数组,我没有学算法,这个是硬写的
by jkluio1 @ 2024-02-07 14:39:14


```cpp #include<iostream> using namespace std; int n; int a[1][7]; int c[1][7]; int cnt = 0; int b[1010][7]; int d[1010]; int main() { cin >> n; int y = n; for (int i = 0; i < 7; i++) { c[1][i] = 0; } for (int i = 0; i < 7; i++) { cin >> a[1][i]; } for (int i = 1; i <= n; i++) { for (int j = 0; j < 7; j++) { cin >> b[i][j]; } } while (n) { cnt = 0; for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if (a[1][i] == b[n][j]) { cnt++; } } } d[n] = cnt; n--; } for (int i = 1; i <= y; i++) { if (d[i] == 7) { c[1][0]++; } else if(d[i]==6) { c[1][1]++; } else if (d[i]== 5) { c[1][2]++; } else if (d[i] == 4) { c[1][3]++; } else if (d[i] == 3) { c[1][4]++; } else if (d[i] == 2) { c[1][5]++; } else if (d[i] == 1) { c[1][6]++; } } for (int i = 0; i < 7; i++) { cout << c[1][i]<<" "; } return 0; } ```
by zq1one @ 2024-02-07 21:04:11


|