您的位置:首页 > 其它

新的学习,新的开始。

2019-04-25 22:53 85 查看
版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/Blue_Tong/article/details/89528092
  • L c语言猜数字游戏程序
    #include<stdio.h>
    #include<stdlib.h>
    #include<time.h>
    #include<string.h>
    #include<math.h>
    void menu()
    {
    printf("***************************\n");
    printf("********* 1.play \n");
    printf("
    0.exit \n");
    printf("
    ****************\n");
    }
    void game()
    {
    int shu = 0;
    int i = rand() % 200 + 1;
    while (1)
    {
    printf(“请输入猜的数字\n”);
    scanf_s("%d", &shu);
    if (shu <i)
    {
    printf(“猜小了\n”);
    }
    else if (shu > i)
    {
    printf(“猜大了\n”);
    }
    else
    {
    printf(“猜对了\n”);
    break;
    }
    };
    }
    int main()
    {
    int input = 0;
    srand((unsigned)time(NULL));
    do
    {
    menu();
    printf(“是否开始游戏?1/0 >:”);
    scanf_s("%d", &input);
    switch (input)
    {
    case 1:
    game();
    break;
    case 0:
    break;
    default:
    printf(“选择错误!\n”);
    break;
    };
    } while (input);
    system(“pause”);
    return 0;
    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: