#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
char c;
freopen("studen.txt","r",stdin);
scanf("%d",&n1);
fclose(stdin);
int l,k;
time_t t;
srand((unsigned) time(&t));
k=rand()%(10+1);
while((c=getchar())!='\0')
{
k=rand()%(10+1);
l=rand()%(10+1); ;
printf("%d%d",k,l);
}
return 0;
}
运行进入死循环,把文件语句去掉却能正常运行
#include<stdlib.h>
#include<time.h>
int main()
{
char c;
freopen("studen.txt","r",stdin);
scanf("%d",&n1);
fclose(stdin);
int l,k;
time_t t;
srand((unsigned) time(&t));
k=rand()%(10+1);
while((c=getchar())!='\0')
{
k=rand()%(10+1);
l=rand()%(10+1); ;
printf("%d%d",k,l);
}
return 0;
}
运行进入死循环,把文件语句去掉却能正常运行