胡辣汤游戏
来源:互联网 发布:俄罗斯方块c语言程序 编辑:程序博客网 时间:2024/05/16 11:46
几碗胡辣汤。
由导演报出胡辣汤晚数,成员从1到5依顺序下蹲,比如报1碗,一号下蹲,2碗,二三号下蹲,3碗,451号下蹲。依次类推,导演随机报数
输入:
3
1 2 3
输出:
N Y N
#include <stdio.h>
#include <stdlib.h>int main()
{
int p,index,i=0,a[100];
int cnt=1; //当前第一个
char str[100]={0},ch;
scanf("%d",&p);
do
{
scanf("%d",&a[i]);
i++;
}while((ch=getchar())!='\n'); //判断是否输入了回车符
index = i;
for(i=0;i<index;i++)
{
if(cnt == p)
str[i] = 'Y';
else if(cnt>p && (cnt+a[i]-1)%5>=p)
str[i] = 'Y';
else if(cnt<p && (cnt+a[i]-1)>=p)
str[i] = 'Y';
else
str[i] = 'N';
cnt=(cnt+a[i])%5; //下一个循环的第一个蹲的
}
for(i=0;i<index-1;i++)
printf("%c ",str[i]);
printf("%c",str[i]);
return 0;
}
0 0