UVa 12554 - A Special "Happy Birthday" Song!!!

題目:過生日唱生日歌,每人唱一二個單詞,每個人都要至少唱一個單詞,

            最後停止時要正好唱完一個循環。

分析:簡單題,模擬輸出即可,設置一個標誌位,所有人唱完標誌成1,

            每次唱完一個循環就判斷是否結束即可。

說明:600題還很遙遠╮(╯▽╰)╭。

#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;
		while (!flag || sing) {
			printf("%s: %s\n",name[now],song[sing]);
			sing = (sing+1)%16;
			if (++ now == n) {
				now = 0;
				flag = 1;
			}
		}
	}
    return 0;
}


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。