11401人加入学习
(31人评价)
【旧版】C++编程系列 预备季快速上手

旧版课程,制作完成于2017-12-18

价格 免费

猜数字游戏

#include<iostream>

#include<string>

#include<time.h>

using namespace std;

int main()

{

cout<<"Guess number"<<endl;

srand((int)time(0));

int number=rand()%10+1;

bool isSuccess=false;

for(int i=0;i<5;i++){

cout<<"I am thinking a number between 1-10,could you guess this number?You guess what:";

int numberGuess;

cin>>numberGuess;

if(numberGuess>number){

cout<<"It is larger than the number."<<endl;

}

else if(numberGuess==numbr){

isSucess=true;

cout<<"Congratulations,you are right!"<<endl;

break;

}

else{

cout<<"It is smaller than the number."<<endl;

}

}

if(isSucess){

}

else{

cout<<"You failed";

}
return 0;

}

[展开全文]

授课教师

SiKi学院老师

课程特色

图文(1)
下载资料(2)
视频(40)