请大家看一看有没有更简单的方法,或意见
  • 板块学术版
  • 楼主oyht123
  • 当前回复6
  • 已保存回复6
  • 发布时间2022/5/20 22:16
  • 上次更新2023/10/28 01:01:20
查看原帖
请大家看一看有没有更简单的方法,或意见
708533
oyht123楼主2022/5/20 22:16
#include<iostream>
#include<ctime>
#include<cstdlib>
using namespace std;
int b;
long long n;
int a;
void kscsbpd(int _) { //抽数字并判断
	int b;
	for(int i=9; i>=0; i--) {
		cin>>b;
		if(b>_) {
			cout<<b<<"太大了"<<endl;
		} else if(b<_) {
			cout<<b<<"太小了"<<endl;
		} else {
			cout<<"你太棒了,数字就是"<<_;
			return 0;
		}
		cout<<"还剩"<<i<<"次机会"<<endl;
	}
	cout<<"加油鸭!,数字是:"<<_;
}

int main(void) {
	cout<<"欢迎来到猜数字游戏,考验你的数学思维"<<endl;
	srand(time(NULL));
	for(int i=1; i<=10; i++) {
		n=rand()%1001;
	}
	cout<<"数在1-1000之间,抽十次"<<endl;
	kscsbpd(n);
	return 0;
}
2022/5/20 22:16
加载中...