可能会错
原题链接:183086.随机数2026-11-14 17:16:37
发布于:广东
本来是:
#include <iostream>
#include <cstdlib>
#include <ctime>
int main() {
std::srand(std: :time(0));
int random_num = std: :rand() % 5 + 1;
std: :cout << random_num << std::endl;
return 0;
}
但因他是随机的,所以把“%5+1”改成“%1+1”哦:
#include <iostream>
#include <cstdlib>
#include <ctime>
int main() {
std: :srand(std: :time(0));
int random_num = std: :rand() % 1 + 1;
std: :cout << random_num << std: :endl;
return 0;
}
这里空空如也


















有帮助,赞一个