#include#include int main() { char buf[27]=""; srand((unsigned)time(NULL));//设置随机种子 for(int i = 0;i<26;++i) { switch(rand()%2+1) { case 1: //小写字母 buf[i] = rand()%26+'a'; break; case 2: //大写字母 buf[i] = rand()%26+'A'; break; } } cout< 运行结果:

#include#include int main() { char buf[27]=""; srand((unsigned)time(NULL));//设置随机种子 for(int i = 0;i<26;++i) { switch(rand()%2+1) { case 1: //小写字母 buf[i] = rand()%26+'a'; break; case 2: //大写字母 buf[i] = rand()%26+'A'; break; } } cout< 运行结果: