猜数字游戏求助
  • 板块灌水区
  • 楼主ShadowCoder
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/9/10 18:16
  • 上次更新2023/11/2 21:35:27
查看原帖
猜数字游戏求助
696288
ShadowCoder楼主2023/9/10 18:16

rt,为什么这每次都生成41

#include <bits/stdc++.h>

using namespace std;
#define int long long
#define For(i, n) for (int i = 0; i < (n); i++)
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    time(NULL);
    int ran = rand() % 100;
    int user, cnt = 0;
    cout << "statue >>> ";
    cin >> user;
    while (user != ran) {
        if (user > ran) {
            cout << "bigger" << endl;
            cout << "statue >>> ";
            cin >> user;
        } else if (user < ran) {
            cout << "smaller" << endl;
            cout << "statue >>> ";
            cin >> user;
        }
        cnt++;
    }
    cout << "right! you tried " << cnt << " times" << endl;
    return 0;
}

2023/9/10 18:16
加载中...