#include <stdio.h> int main() { char colour; while (scanf("%c", &colour) != EOF) { if (colour >= 'a' && colour <= 'z') { if (colour == 'r') { printf("stop!\n"); } else if (colour == 'y') { printf("wait a minute\n"); } else if (colour == 'g') { printf("go go go\n"); } else { printf("something must be wrong...\n"); } } } return 0; }
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
int day;
srand(time(0));
day = rand() % 30;
int chance;
int guess;
printf("猜猜2023年11月哪一天会是你的lucky day,你有三次机会:");
for (chance = 3; chance > 0; chance--) {
scanf("%d", &guess);
if (guess == day) {
printf("right!\n");
return 0;
}
else if (guess > day) {
printf("too late!\n");
}
else if (guess < day) {
printf("too early!\n");
}
if (chance == 1) {
printf("\n");
printf("次数用完了,告诉你,11月,你的lucky day是%d号", day);
}
else {
printf("再猜:");
}
}
return 0;
}
标签:guess,int,chance,实验,printf,include,day From: https://www.cnblogs.com/p2kp2k/p/17767925.html