
本文共 3601 字,大约阅读时间需要 12 分钟。
���������������:���������C������������������������
���������������������������������������������������������������������C������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
##������������
������������������������������������������������������������������������������������������������������������������������
###1. ���������������������
������������������������������������������������������������������������������������������������������������"1. ������������" ��� "2. ������������"���
###2. ������������������
������������������������������������������������������������������������������������������������������������������������������������������������
###3. ���������������������
���������������������������������������������������������������������������������������"������������������"���"������������������"���������������"������������"���
###4. ������������
���������������������������������������������������������������������������������������������������������������������������������������������������������������������
##������������������
���������������������������������������
###1. include���������
#include#include #include
������������������C���������������������������������������������������������������������������
###2. ������������������
void game(){ int ret = rand() % 100 + 1; // ������������������������ int num = 0; while(1) { printf("������������������:"); scanf("%d", &num); if (num > ret) { printf("���������������������\n"); } else if (num < ret) { printf("���������������������\n"); } else { printf("������������!\n"); break; // game��������������������������������� } }}
- ������������������������
rand()
������������1���100������������������������������������������ - ���������������������������
while(1)
������������������������������������������������������ - ������������������������������������������������������������������������������������������
###3. ������������������������
int menu(){ printf("���������1���������������������2���������������\n"); int choice = 0; scanf("%d", &choice); return choice;}
- ���������������������������������������������������������������1���2���
- ������������������������������������������������������������������������������������
###4. ���������������������
int main(){ srand(time(0)); // Set��������������� while(1) { int choice = menu(); // ������������������ if (choice == 1) { game(); // ������������ } else if (choice == 2) { printf("���������������\n"); break; } } system("pause"); return 0;}
- ���������������������������
time(0)
��������������������������������������������������������������������������� - ���������������������������������������������������������
- ���������������������������������������������2���������������������������������������
������
������������������������������������������������������������������������������������������������������������������������������������������������������������rand()
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������C������������������������������
发表评论
最新留言
关于作者
