某本校月赛出的ex题
遇到这题我第一个想到的就是随机数
我的代码如下:
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
using namespace std;
long long random_num(int radix){
timeval t;
gettimeofday(&t,NULL);
return t.tv_usec%radix;
}
char alphabet[26]={'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'};
string gen_random_str(int length){
string result;
for(int i=0;i<length;i++){
result+=alphabet[random_num(26)];
usleep(1);
}
return result;
}
int main(){
int a,b;
cin>>a>>b;
for(int i=0;i<b-1;i++){
cout<<gen_random_str(10)<<' ';
}
return 0;
}