题意:唱生日快乐歌,如果人数少于16个,就每人一句接下去,重复唱,直到歌曲唱完。如果超过16个人,就必须每人至少唱一句,也要求必须整首歌唱完,不能中途停下。
思路:有点水,不过要注意切换,整首歌的下半部分,唱的的是“to Rujia”,要记得换过来
#include <iostream>
#include <cstdio>
#include <cstring>
#define N 110
using namespace std;
char name[N][N];
char s1[16][20] = {"Happy", "birthday", "to", "you", "Happy", "birthday", "to", "you",
"Happy", "birthday", "to", "Rujia", "Happy", "birthday", "to", "you"};
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
scanf("%s", name[i]);
int m = (n / 16 + 1) * 16;
for (int i = 0; i < m; i++) {
printf("%s: %s\n", name[i % n], s1[i % 16]);
}
return 0;
}