#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
char *p;
int n;
while(~scanf("%d",&n))
{
p=(char *)malloc(n*sizeof(char));
if(p==NULL)
{
printf("No Enough Memory\n");
exit(0);
}
srand((unsigned)time(0));
int i,index;
for(i=0; i<n; i++)
{
index=rand()%2;
if(index==1) p[i]='A'+rand()%26;
if(index==0) p[i]='a'+rand()%26;
}
printf("%s\n",p);
free(p);
}
return 0;
}
为啥输出结果里会含有一个'?',而且输出有时还会乱码?刚学到这不知道哎