语c猜数字惩罚后缀最新完整版

猜数字游戏(C语言版) - 开源中国社区
当前访客身份:游客 [
当前位置:
发布于 日 19时,
没啥可以说的&GCC编译可以!别的没试。。
代码片段(1)
1.&[代码][C/C++]代码&&&&
#include &time.h&
#include &stdio.h&
#include &stdlib.h&
#include &ctype.h&
int count , number ,
char yes = 'Y';
printf("\n now let us play the game ,\n Guess the number");
srand((int)time(0));
number = 1+(int)(100.0*rand()/(RAND_MAX+1.0));
//如果想偷懒 这里显示***
//printf("%d\n", number);
printf("\n Input an integer number(1-100): ");
scanf("%d",&guess);
}while(!(guess&1 && guess &=100));
if (guess==number)
printf("\ngongxi ni caidui le
thank you");
number = 1+(int)(100.0*rand()/(RAND_MAX+1.0));
//如果想偷懒 这里显示***
//printf("%d\n", number);
printf("\nNEXT?(Y/N):");
scanf("%s",&yes);
if (guess&number)
printf("\nYour answer is LOW ,try again\n");
if (guess&number)
printf("\nYour answer is high ,try again\n");
} while (guess==number);
if (count==15)
printf("\n That is the %d time ! think is hard next!");
if (count&=7)
printf("\n You have got it in %d times \n",count);
printf("\n Congretulations");
printf("\n You got it in %d times \n",count);
printf("\n bet you can do it better");
}while(toupper(yes)=='Y');
开源中国-程序员在线工具:
相关的代码(2869)
开源从代码分享开始
被淹死的鱼鱼的其它代码语C猜数字惩罚怎么整理_百度知道c语言猜数字有一定的容错功能,界面友好,功能齐全。游戏规则: a,一个四位数,各位上的数字不重复,从1到9。b,按以下提示猜出这个四位数。 c,每次猜测输入的数据给出类似的提示*A*B。d,其中A前的*代表你本次猜对了多少个数字。 e,其中B前的*代表你本次猜对的数字并且位置正确的个数。可以用的,准确的,我追加10分大哥们,救救急啊。
#include #include #include #include void main_menu(void);void score_menu(int score);void help_menu(void);int play_game(void) ;int main() { char main_menu_ int score = 0; while (1) {
main_menu(); //输出主菜单目录
main_menu_choose = 'y';
temp = getch();
if (temp >= '0' && temp <= '3') {
main_menu_choose =
} while (main_menu_choose == 'y');
switch(main_menu_choose){
score = play_game();
score_menu(score);
help_menu();
} }}void main_menu(void){ printf("1:开始游戏!2:查看上次成绩!3:输出帮助信息!0:退出程序!\n");}void score_menu(int score){ printf("分数是:%d\n", score); printf("任意键返回主目录:\n"); getch();}void help_menu(void){ printf("帮助信息:\n"); printf("任意键返回主目录:\n"); getch();}int play_game(void) { char target[4]; char guess[4]; int input_ char game_ char input_ unsigned int i, j, x, int score = 100; srand(time(NULL)); target[0] = '0' + rand() % 10; target[1] = '0' + rand() % 10; target[2] = '0' + rand() % 10; target[3] = '0' + rand() % 10; printf("Input your guess:\n"); game_flag = 'y'; while (game_flag == 'y' || game_flag == 'Y') {
input_flag = 3;
printf("输入你猜测的数值:\n");
while (input_flag >= 0) {
input_temp = getchar();
guess[input_flag] = input_
input_flag--;
if(input_temp == 'n' || input_temp == 'N'){
game_flag = 'n';
x = y = 0;
for (i = 0; i < 4; ++i) {
if (target[i] == guess[i]) {
for (j = i + 1; j < 4; ++j) {
if (target[i] == guess[j]) {
if (x != 4) {
printf("%dA %dB\n", y, x);
getchar();
score -= 10;
printf("恭喜你猜对了!\n");
} } return 0;}界面不是很好,留给你自己设计了。
为您推荐:
扫描下载二维码(小跖天下无敌!)
第三方登录:语C群猜数字的惩罚有哪些后缀......_百度知道

参考资料

 

随机推荐