这代码我能玩一天
  • 板块灌水区
  • 楼主applesandwich
  • 当前回复4
  • 已保存回复4
  • 发布时间2025/1/21 11:33
  • 上次更新2025/1/21 14:43:16
查看原帖
这代码我能玩一天
1631814
applesandwich楼主2025/1/21 11:33

代码如下

#include <bits/stdc++.h>
#include <cstdlib>
#include <ctime> 
using namespace std;
long long a,b;
int main()
{
    std::srand(static_cast<long long>(std::time(0)));
	b=std::rand()%100;
	cout<<"猜数游戏,请输入猜的数"<<endl; 
	for(int i=1;;i++)
	{
		cin>>a;
		if(a>b)
		cout<<"big"<<endl;
		else if(a<b)
		cout<<"small"<<endl;
		else if(a==b)
		{
			cout<<"it is true"<<endl;
			break;
		}
	}
	return 0;
}

求大佬加个检测a是否是long long int型

如果不是就输出“unknow number”

谢谢

2025/1/21 11:33
加载中...