首页 > 移动平台 > 详细

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

时间:2015-03-04 22:41:35      阅读:206      评论:0      收藏:0      [点我收藏+]

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

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

分析:簡單題,模擬輸出即可,設置一個標誌位,所有人唱完標誌成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;
}


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

原文:http://blog.csdn.net/mobius_strip/article/details/44067427

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!