怎么样C语言随即输出指定的几个英语字母

来源:百度知道 编辑:UC知道 时间:2024/05/25 07:19:15
比如“ u i o j k l m ”
四个一排 输出500排 并用记事本导出

挺简单的小题,自己应该编编的:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
FILE *p;
p=fopen("D:\\output.txt","w");
if(p==NULL)
{
printf("建立文件错误\n");
system("pause");
exit(0);
}
else
{
int x;
char tem[7]={'u','i','o','j','k','l','m'};
srand((unsigned)time(NULL));
for(int i=1;i<=500;i++)
{
for(int j=1;j<=4;j++)
{
x=rand()%7;
fprintf(p,"%c ",tem[x]);

}
fprintf(p,"\n");
}
fclose(p);

}
return 0;
}

代码如下:
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
freopen("output.txt","w",stdout);
string s;
c