如何输出随机字符?
C++如何输出随机字符?(数字或大小写)
#include<stdio.h>
#include<string.h>
int main()
{
char p[26+26+10];
int i, j, k, n;
for (i=0; i<26; p[i]='A'+i, i++);
for (j=0; j<26; p[i]='a'+j, i++, j++);
for (k=0; k<10; p[i]='0'+k, i++, k++);
srand((unsigned)time(0));
while (1) {
n = rand()%62;
putchar(p[n]);
}
return 0;
}
输出随机字符
QAWdQompvGVvPftfbdFKDIqed8rZQ5Lf4h8KLix4nJp0mYTE0YO1e2W71DUF6fkyCh7LFuFq1sgeH0g5MswrkGmZH7fEcF2dmzoqisWZa11frXa3DLioRLDXGibimR9MFm2nUNAsC0OtNmkPxH3DQ4aWbz2DE2NHcGuwRteTjqAuTi9Gn0H3tfNKUGLX6WeYcNIr6k8dR6NidLmGBu8sPL0iP95JWXhwknegOa7dXLByUn4TV0CjC2HP2AZOX4A6icau3YNOhMA1z2KJtMstDx85xVHIQFEwifeZ1rlY1lPodZxKkf3nQ2gDLlKZqMLMpplgUK4LvHyNhlXFFRqVHMXQxfqdr1oXfP3xYw7H3vUYUqdZ5JtATEQGj6iQyMnRZfExRB5KuNhF3AcwILwbPDiy9EFvOqAnLFZaEUjzfG4XGWJOg4qv7Mi4OlocRoFbre1wwajSgbnlvwxRqbBlnhg1IITXwXwe1oOmCv4hMfI7R3N6VMh8rByzJFK4c7WSjk4lVwGfRMaiGlcbx8Zc9LRHRaBtVXB453dOpkt6wHd2t5Te3r712M8Hm717U0zNuTbZ1IUnNxe6qvbkcWbTiXaJUPEmE4zyLOLCUfnhQHc731hTN6mtTB2lQ5NUxAG8MS8evlBCtb9kSe3daeNrfDSv8dEvbKtnarHMRGO8gLiypZSD3duWgAGfbKO2S6dtli52mH0ISW55uN8loq8KoEnFM25eyYLZ4EQgJEpbbiUJtSuX8shkuLp4DkZz6iM0ncXufAK4geDPxxmteJUOS7JVigIcCVTnvoYOmiIICLXx77fbGxnZuusQOztRIA43mQIOyOUzapkXmFws2ZFlKw1YlintigkKwqWj5qW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