产生随机字符串

来源:互联网 发布:linux ftp配置 编辑:程序博客网 时间:2024/05/01 08:16
#include<iostream>#include<fstream>#include<ctime>#include<string>#define cout foutusing namespace std;ofstream fout("Dict12.txt");int main(){srand((unsigned) time(NULL));for (int k=0; k<10016; ++k){int len = rand() % 19; //len为字符串长度string Word;Word = new char[len];int i;for (i=0; i<len; ++i){   //相应根据随机数产生一个字符int num = rand() % 25;char c = 'a' + num;Word[i] = c;      }Word[i] = '\0';    cout<<Word<<". ";if(k % 15 == 0) cout <<endl;}return 0;}

0 0
原创粉丝点击