龙凤苑中学4月15日练习赛
Done
IOI
Start at: 2026-4-15 16:00
24
hour(s)
Host:
14
#include <bits/stdc++.h>
using namespace std;
int main() {
// ---------- 1. 定义变量 ----------
int ticket_count; // 小明买的彩票张数
int winning_numbers[8] = {0}; // 存储7个中奖号码(下标1~7,方便循环)
int prize_counts[8] = {0}; // 统计奖项:prize_counts[k] = 有k个号码匹配的彩票数(k=1~7)
// ---------- 2. 输入中奖号码 ----------
cin >> ticket_count; // 读入彩票张数
for (int i = 1; i <= 7; i++) { // 读入7个中奖号码,存入winning_numbers[1]~[7]
cin >> winning_numbers[i];
}
// ---------- 3. 处理每张彩票 ----------
for (int t = 1; t <= ticket_count; t++) { // 遍历每张彩票
int match_count = 0; // 记录当前彩票与中奖号码的匹配数,初始为0
for (int num = 1; num <= 7; num++) { // 读入当前彩票的7个号码
int current_num; // 存储当前读入的彩票号码
cin >> current_num;
// 与每个中奖号码比较,判断是否匹配
for (int win = 1; win <= 7; win++) {
if (current_num == winning_numbers[win]) {
match_count++; // 匹配到,计数+1
break; // 号码不重复,找到就跳出,避免多余比较
}
}
}
// 根据匹配数,更新对应奖项的计数(如match_count=7 → 特等奖,prize_counts[7]++)
prize_counts[match_count]++;
}
// ---------- 4. 输出结果 ----------
// 按 特等奖(7个)→一等奖(6个)→…→六等奖(1个) 的顺序输出
for (int k = 7; k >= 1; k--) {
cout << prize_counts[k] << " ";
}
return 0;
}
- Status
- Done
- Rule
- IOI
- Problem
- 6
- Start at
- 2026-4-15 16:00
- End at
- 2026-4-16 16:00
- Duration
- 24 hour(s)
- Host
- Partic.
- 14