欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來(lái)到入門教程網(wǎng)!

C語(yǔ)言

當(dāng)前位置:主頁(yè) > 軟件編程 > C語(yǔ)言 >

C語(yǔ)言實(shí)現(xiàn)猜數(shù)字小游戲

來(lái)源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語(yǔ)言|點(diǎn)擊: 次

本文實(shí)例為大家分享了C語(yǔ)言猜數(shù)字的具體代碼,供大家參考,具體內(nèi)容如下

一、描述

猜數(shù)字游戲。

二、 程序

使用srand((unsigned)time(NULL)),產(chǎn)生隨機(jī)數(shù)種子。
int random = rand() % 100 + 1,產(chǎn)生0~100之間的隨機(jī)數(shù)。
應(yīng)加上頭文件#include<time.h>

#include<stdio.h>
#include<windows.h>
#include<time.h>
void menu(){
 printf("#######################\n");
 printf("#    1 Play    #\n");
 printf("#    0 Exit    #\n");
 printf("#######################\n");
}
void Play(){
 int m = 0;
 int random = rand() % 100 + 1;
 while (1)
 {
 printf("請(qǐng)輸入一個(gè)數(shù)字:\n");
 scanf_s("%d", &m);
 if (m == random){
  printf("你猜對(duì)了\n");
  break;
 }
 else if (m > random){
  printf("你猜大了,請(qǐng)重新輸入!");
 }
 else{
  printf("你猜小了,請(qǐng)重新輸入!");
 }
 }
}
 int main()
 {
 srand((unsigned)time(NULL));
 int select = 0;
 do {
 menu();
 printf("請(qǐng)選擇:");
 scanf_s("%d", &select);
 switch (select)
 {
 case 1:
  Play();
  break;
 case 0:
  printf("ByeBye!\n");
  break;
 default:
  printf("輸入錯(cuò)誤,請(qǐng)重新輸入!\n");
  break;
 }
 } while (select);
 system("pause");
 return 0;
}

三、運(yùn)行結(jié)果

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:C++實(shí)現(xiàn)推箱子游戲

欄    目:C語(yǔ)言

下一篇:C++貪心算法實(shí)現(xiàn)活動(dòng)安排問(wèn)題(實(shí)例代碼)

本文標(biāo)題:C語(yǔ)言實(shí)現(xiàn)猜數(shù)字小游戲

本文地址:http://mengdiqiu.com.cn/a1/Cyuyan/141.html

網(wǎng)頁(yè)制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語(yǔ)言數(shù)據(jù)庫(kù)服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有