#includeusing namespace std; #include #include int main() { srand(time(NULL)); // 使用系统当前时间设置随机数种子 int data = rand() % 100 + 1; // 生成一个随机数 int key = 0; while (true) { cout << "请输入一个数字>"; cin >> key; if (key == data) { cout << "猜对了" << endl; break; } else if (key < data) { cout << "猜小了" << endl; } else { cout << "猜大了" << endl; } } return 0; }



