Title: Sing a birthday song on the birthday, each person sings one or two words, each person must sing at least one word,
Stop at the end to sing a loop.
Analysis: Simple problem, simulation output can be, set a sign, all of us to sing 1,
Each time you finish a loop, you will be judged if you are finished.
SAY: 600 questions are still very remote ╮(╯▽╰)╭.
#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include < Cstdio> #include <cmath>using namespace Std;char name[101][101];char song[16][9] = {"Happy", "Birthday", "to", " You ', ' Happy ', ' birthday ', ' to ', ' you ', ' Happy ', ' birthday ', ' to ', ' Rujia ', ' Happy ', ' birthday ', ' to ', ' You '};int main () { int N;while (~SCANF ("%d", &n)) {for (int i = 0; i < n; + + i) scanf ("%s", name[i]); int flag = 0,sing = 0,now = 0;whi Le (!flag | | sing) {printf ("%s:%s\n", name[now],song[sing]); sing = (sing+1)%16;if (+ + now = N) {now = 0;flag = 1;}}} return 0;}
UVa 12554-a Special "Happy Birthday" Song!!!