求解随机字符串,悬一关
  • 板块灌水区
  • 楼主ylswznzs
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/3/8 21:39
  • 上次更新2024/3/9 08:36:53
查看原帖
求解随机字符串,悬一关
1117573
ylswznzs楼主2024/3/8 21:39
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
string p[10]={"wu","rumen","puji","tigao","shengxuan","NOI"};
string make()//随机字符串
{
    string e="";
    srand(time(0));
    int x=rand()%40;
    while(x--)
    {
        //srand(time(0));
        e+=(char)(rand()%90+32);
    }
    return e;
}
void sc(long x/*组数*/)//生成字符串+数字+字符串
{
    srand(time(0));
    while(x--)
    {
        cout<<make()<<' '<<rand()%300<<' '<<p[rand()%5-1]<<endl;
    }
}
int main()
{
    long n;
    cin>>n;
    sc(n);
    return 0;
}

希望输出不同的,如:

输入

3

输出

iofejof 44 puji
jifjeofwj 22 tigao
fjeiowqfjncn 24 rumen

可是他生成的全一样……

2024/3/8 21:39
加载中...