0-100的猜数字游戏

//0-100的猜数字游戏
#define _CRT_SECURE_NO_WARNINGS
#include
#include
#include
#include

int main() {
int i;
int choice;
int iguess;
printf("=\n");
printf("=1.开始游戏
\n");
printf("=0.退出游戏
\n");
printf("
=====\n");
printf(“请输入你的选择:(1或者0):\n”);
srand(time(NULL));
int isecret = rand() % 100 + 1;
scanf("%d", &choice);

for (i = 0; i <= 100; i++) {
	if (choice == 1) {
		printf("输入你猜的数字: ");
		scanf("%d", &iguess);
		if (isecret > iguess) {
			printf("数字小了!\n");
		}
		else if (isecret < iguess) {
			printf("数字大了!\n");
		}
		else {
			printf("猜对了!\n");
			break;
		}
	}
	else if (choice == 0) {
		break;
	}
	else {
		break;
	}
}

system("pause");
return 0;

}

你可能感兴趣的:(0-100的猜数字游戏)