#include<stdio.h> #include<stdlib.h> #include<string.h> #include<time.h>
int main() { int j=0,x,a[1024]; char rand_num[5]; FILE *stream=fopen("1.txt","w"); srand((unsigned)time(NULL)); for(int i=0;i<500;i++) { x=rand()%100; sprintf(rand_num,"%d\n",x); fputs(rand_num,stream); } fclose(stream); stream=fopen("1.txt","r"); i=0; while(!feof(stream))fscanf(stream,"%d",&a[i++]); for(i=0;i<500;i++)printf("%d\t",a[i]); printf("\n"); fclose(stream); return 0; }