问题是:Totals 游戏可以由任意数量的人玩。它从总共 100 开始,然后每个玩家依次在 -20 到 20 之间进行整数位移。获胜者是调整使总数等于 5 的玩家。仅使用给定的三个变量: 总调整计数器 这是我目前所拥有的:
#include <stdio.h>
int main (void)
{
int counter=0;
float adj;
int ttl=100;
printf("You all know the rules now lets begin!!!\n\n\nWe start with 100. What is\n");
while (ttl!=5)
{
printf("YOUR ADJUSTMENT?");
scanf("%f",&adj);
counter++;
if (adj<=20 && adj>=-20)
{
ttl=ttl+adj;
printf("The total is %d\n",ttl);
}
else
{
printf ("I'm sorry. Do you not know the rules?\n");
}
}
printf("The game is won in %d steps!",counter);
}
我需要什么:输入十进制数字时,它会转到其他地方。如何确定浮点数是否有小数部分。