SlienceMC @ 2024-11-06 21:56:40
本菜鸟在红题区刷怪时,遇到了一题全WA,用了示例测试是对的,也看不出为什么,求指点
#include <iostream>
using namespace std;
int main() {
unsigned short a;
cin >> a;
unsigned short lucky_number[7]{ 0 }, b[7]{ 0 };
for (int i = 0; i < 7; i++) cin >> lucky_number[i];
for (int i = a; i > 0; i--) {
unsigned short same=0,d;
for (int n = 0; n < 7; n++) {
cin >> d;
for (unsigned short ii : lucky_number) {
if (ii == d) same++;
}
}
b[same-1]++;
}
for (int i = 6; i > -1; i--) cout << b[i] << " ";
return 0;
}
by easy42 @ 2024-11-06 22:20:28
@SlienceMC 数组开小了,求关注。
#include <iostream>
using namespace std;
int main() {
unsigned short a;
cin >> a;
unsigned short lucky_number[70]{ 0 }, b[70]{ 0 };
for (int i = 0; i < 7; i++) cin >> lucky_number[i];
for (int i = a; i > 0; i--) {
unsigned short same=0,d;
for (int n = 0; n < 7; n++) {
cin >> d;
for (unsigned short ii : lucky_number) {
if (ii == d) same++;
}
}
b[same-1]++;
}
for (int i = 6; i > -1; i--) cout << b[i] << " ";
return 0;
}
by SlienceMC @ 2024-11-07 08:02:03
@easy42 多谢指点