猜数游戏

#include
#include#include#include<windows.h>using namespace std;int main(){ srand(time(0)); int n=rand()%1000; int c=-1,ans=0; cout<<“你要猜的数字为:***”<<endl<<endl; while(c!=n){ cout<<“你猜的数是:”; cin>>c; ans++; if(c>n){ Sleep(500); cout<<“大了!”<<endl<<endl; } else if(c<n){ Sleep(500); cout<<“小了!”<<endl<<endl; } } cout<<“恭喜猜中!!!”<<endl<<“共用了”<<ans<<“次!!!”<<endl; system(“pause”); return 0;}

上一篇:51单片机标准函数stdlib.h利用rand随机数闪烁led+Proteus仿真


下一篇:python中“TypeError: Can't convert 'int' object to str implicitly"报错的解决办法