代码求调
  • 板块学术版
  • 楼主JYC130604
  • 当前回复2
  • 已保存回复2
  • 发布时间2025/1/18 20:46
  • 上次更新2025/1/19 08:21:15
查看原帖
代码求调
1252199
JYC130604楼主2025/1/18 20:46

谁能帮我把这个程序的随机数调好?每次都是1个n,一个ans,一个sum,一个siz QAQ

#include  <bits/stdc++.h>
#include  <cstdlib>
#include  <ctime>
using namespace std;
string s;
char randa[62]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9'};
int main(){
	srand(0);
	int n=rand()%10;
	cout<<n<<endl;
	for(int i=1;i<=n;i++){
		srand(0);
		int siz=rand()%300+1;
		for(int j=1;j<=siz;j++){
			srand(0);
			int ans=rand()%62;
			s+=randa[ans];
		}
		cout<<s<<" ";
		srand(0);
		int sum=rand()%5+1;
		cout<<sum<<endl;
	}
	return 0;
}
2025/1/18 20:46
加载中...