单选题有以下程序:#include main(){ FILE *fp; int i,a[6]={1,2,3,4,5,6}; fp=fopen(d2.dat,w+); for(i=0;i6;i++) fprintf(fp,%d, a[i]); rewind(fp); for(i=0;i6;i++) fscanf(fp,%d, a[5-i]); fclose(fp); for(i=0;i6;i++) printf(%d,, a[i]);}程序运行后的结果是( )。A4,5,6,1,2,3,B1,2,3,3,2,1,C1,2,3,4,5,6,D6,5,4,3,2,1,
单选题
有以下程序:#include main(){ FILE *fp; int i,a[6]={1,2,3,4,5,6}; fp=fopen(d2.dat,w+); for(i=0;i<6;i++) fprintf(fp,%d, a[i]); rewind(fp); for(i=0;i<6;i++) fscanf(fp,%d, &a[5-i]); fclose(fp); for(i=0;i<6;i++) printf(%d,, a[i]);}程序运行后的结果是( )。
A
4,5,6,1,2,3,
B
1,2,3,3,2,1,
C
1,2,3,4,5,6,
D
6,5,4,3,2,1,
参考解析
解析:
函数的功能是将数组a中的元素顺序写入文件,再将文件中的元素倒序读出存储到数组a中,最后输出数组a的元素,答案选择D选项。
函数的功能是将数组a中的元素顺序写入文件,再将文件中的元素倒序读出存储到数组a中,最后输出数组a的元素,答案选择D选项。
相关考题:
有以下程序includemain(){FILE*fp;int i,a[6]={1,2,3,4,5,6};fp=fopen("d3.dat","w+b" 有以下程序 #include<stdio.h> main() {FILE*fp;int i,a[6]={1,2,3,4,5,6}; fp=fopen("d3.dat","w+b"); fwrite(a,sizeof(int),6,fp); fseek(fp,sizeof(int),3,SEEK_SET);/*该语句使读文件的位置指针从文件头向后移动3个int型数据*/ fread(a,sizeof(int),3,fp);fclose(fp); for(i=0A.4,5,6,4,5,6,B.1,2,3,4,5,6,C.4,5,6,1,2,3,D.6,5,4,3,2,1,
有以下程序includemain(){FILE*fp;inta[10]={1,2,3},i,n;fp=fopen("d1.daf","w");for( 有以下程序 #include <stdio.h> main() {FILE *fp; int a[10]={1,2,3},i,n; fp=fopen("d1.daf","w"); for(i=0;i<3;i++) fprintf(fp,"%d",a[i]); fprintf(fp,"\n"); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d",n); fclose(fp);A.12300B.123C.1D.321
有以下程序includemain(){FILE *fp;int i=20,j=30,k,n;fp=fopen("D1v.dat","w");fprin 有以下程序 #include<stdio.h> main() {FILE *fp;int i=20,j=30,k,n; fp=fopen("D1v.dat","w"); fprintf(fp,"%d\n",i);fprintf(fp,"%d\n",j); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d%d",k,n);printf("%d%d\n",k,n); fclose(fp); } 程序运行后的输出结果是( )。A.20 30B.20 50C.30 50D.30 20
有以下程序 include main(){FILE *fp;int i; char ch[]="abcd",t; fp=fopen("abc.dat" 有以下程序 #include <stdio.h> main() {FILE *fp; int i; char ch[]="abcd",t; fp=fopen("abc.dat","wb++"); for(i=O;i<4;i++)fwrite(ch[i],1,1,fp); fseek (fp,-2L,SEEK_END); fread (t,1,1,fp); fclose (fp); printf ("%c\n",t); } 程序执行后的输出结果是______。A.dB.cC.bD.a
有以下程序 include main() { FILE *fp;int k,n,a[6]={1,2,3,4,5,6}; f 有以下程序 #include<stdio.h> main() { FILE *fp;int k,n,a[6]={1,2,3,4,5,6}; fp=fopen("d2.dat","w"); fprintf(fp,"%d%d%d\n",a[0],a[1],a[2]);fprintf(fp,"%d%d%d\n",a[3],a[4],a[5]); fclose(fp); fp=fopen("d2.daf","r"); fscanf(fp,"%d%d",k,n);printf("%d%d\n",k,n); fclose(fp); } 程序运行后的输出结果是A.1 2B.1 4C.123 4D.123 456
有以下程序 include main() { FILE *fp;int i,a[6]={1,2,3,4,5,6}; fp= 有以下程序 #include<stdio.h> main() { FILE *fp;int i,a[6]={1,2,3,4,5,6}; fp=fopen("d3.dat","w+b"); fwrite(a.sizeof(int),6,fp); fseek(fp,sizeof(int)*3,SEEK_SET):/*该语句使读文件的位置指针从文件头向后移动3个int型数据*/ fread(a,sizeof(int),3,fp);fclose(fp); for(i=0;i<6;i++)printf("%d,",a[i]); } 程序运行后的输出结果是A.4,5,6,4,5,6,B.1,2,3,4,5,6,C.4,5,6,1,2,3,D.6,5,4,3,2,1,
有以下程序:includemain(){FILE *fp;int i,k=0,n=0;fp=fopen("d1.dat","w");for(i=1;i 有以下程序: #include<stdio.h> main() { FILE *fp; int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i=1;i<4;i++) fprintf(fp,"%d",i); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d%d",k,n); printf("%d %d\n", k,n); fclose(fp); } 执行后输出结果是( )。A.1 2B.123 0C.1 23D.0 0
有下列程序: include main() { FILE *fp; int a[10]={1,2,3},i,n; 有下列程序: #include <stdio.h> main() { FILE *fp; int a[10]={1,2,3},i,n; fp=fopen("d1.dat","w"); for(i=0;i<3;i++) fprintf(fp,"%d",a[i]); fprintf(fp,"\n"); fclose(fp); fp=open("d1.dat","r"); fscanf(fp,"%d",n); fclose(fp); prinff("%d\n",n); 程序的运行结果是( )。A.12300B.123C.1D.321
有以下程序:include main(){FILE*fp;int i,k,n; fp=fopen("data.dar","w+");for(i=1;i 有以下程序: #include <stdio.h> main() { FILE *fp; int i,k,n; fp=fopen("data.dar","w+"); for(i=1;i<6;i++) { fprintf(fp,"%d ",i); if(i%3==0) fprintf(fp,"\n"); } rewind(fp); fscanf(fp,"%d%d",k,n); printf("%d%d\n",k,n); fclose(fp); } 程序运行后的输出结果是( )。A.0 0B.123 45C.1 4D.1 2
有以下程序 include main() { FILE *fp; int' a[10]={1,2,3,0,0},i; 有以下程序 #include <stdio.h> main() { FILE *fp; int' a[10]={1,2,3,0,0},i; fp = fopen("d2.dat", "wb"); fwrite(a, sizeof(int), 5, fp); fwrite(a, sizeof(int), 5, fp); fclose(fp); fp = fopenCd2.dat", "rb"); fread(a, sizeof(int), 10, fp); fclose(fp); for (i=0; i<10; i++) printf("%d,", a[i]); }A.1,2,3,0,0,0,0,0,0,0,B.1,2,3,1,2,3,0,0,0,0,C.123,0,0,0,0,123,0,0,0,0,D.1,2,3,0,0,1,2,3,0,0,
有以下程序include main(){FILE *fp;int i=20,j=30,k,n;fp=fopen("d1.dat","w");fprin 有以下程序 #include <stdio.h> main() { FILE *fp; int i=20,j=30,k,n; fp=fopen("d1.dat","w"); fprintf(fp,"%d\n",i);fprintf(fp,"%d\n",j); fclose(fp); fp=fopen("d1.dat", "r"); fp=fscanf(fp,"%d%d",k,n); printf("%d%d\n",k,n); fclose(fp); } 程序运行后的输出结果是A.20 30B.20 50C.30 50D.3020
有以下程序:include main( ){FILE * fp; int i,k,n;fp = fopen( "data. dat" ,"w +" ) 有以下程序:#include <stdlo.h>main( ){ FILE * fp; int i,k,n; fp = fopen( "data. dat" ,"w +" ) for(i = 1 ;i<6;i ++ ) { fprintf(fp."% d",i); if(i%3 ==0)fprintf(fp," \n"); } rewind(fp); fscanf(fp." % d% d" ,k, n) ;printf(" % d%d \n" ,k,n); fclose(fp);A.0 0B.123 45C.1 4D.1
有以下程序: include main() {FILE *fp; int i,k,n; fp=fopen("data 有以下程序: #include <stdio.h> main() {FILE *fp; int i,k,n; fp=fopen("data.dat","w+"); for(i=1;i<6;i++) {fprintf(fp,"%d ",i); if(i%3==0) fprintf(fp,"\n"); } rewind(fp); fscanf(fp,"%d%d",k,n); printf("%d %d\n",k,n); fclose(fp); } 程序运行后的输出结果是 ______。A.0 0B.123 45C.1 4D.1 2
有以下程序:include main()FILE *fp; int i,k=0,n=0;fp=fopen("d1.dat","w");for(i=l 有以下程序: #include <stdio.h> main() FILE *fp; int i, k=0, n=0; fp=fopen("d1.dat","w"); for(i=l;i<4;i++) fprintf(fp,"%d",i); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,'%d%d",k,n); printf("%d %d\n", k, n); fclose(fp); 执行后输出结果是A.1 2B.123 0C.1 23D.0 0
有以下程序include main(){FILE*fp;inti,k,n;fp=fopen("data.dar","w+");for(i=1;i 有以下程序 #include <stdio.h> main() { FILE *fp; int i,k,n; fp=fopen("data.dar", "w+"); for(i=1;i<6;i++) { fprintf(fp,"%d ",1); if(i%3==0) fprintf(fp, "\n"); } rewind(fp); fscanf(fp, "%d%d",k,n); printf. ("%d %d\n",k,n); fclose(fp); } 程序运行后的输出结果是A.0 0B.123 45C.1 4D.1 2
有以下程序:includemain(){FILE*fp;int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i=1; 有以下程序: #include <stdio.h> main() { FILE *fp;int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i=1;i<4;i++) fprintf(fp,"%d",i); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d%d",k,n);printf("%d%d\n",k,n); fclose(fp); { 执行后的输出结果是( )。A.1 2B.123 0C.1 23D.0 0
有以下程序:includemain(){FILE*fp;int a[10]={1,2,3},i,n;fp=fopen("d1.dat","w");fo 有以下程序: #include<stdio.h> main() {FILE*fp;int a[10]={1,2,3},i,n; fp=fopen("d1.dat","w"); for(i=0;i<3;i++)fprintf(fp,"%d",a[i]); fprintf(fp,"\n"); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d",&n); fclose(fp); printf("%d\n",n); 程序的运行结果是( )。A.12300B.123C.1D.321
有以下程序includemain(){FILE *fp;int i=20,j=30,k,n;fp=fopen("d1.dat","w");fprint 有以下程序 #include<stdio.h> main() {FILE *fp;int i=20,j=30,k,n; fp=fopen("d1.dat","w"); fprintf(fp,"%d\n",i;fprintf(fp,"%d\n",j); fclose(fp); fp=fopen("d1.dat","r"); fscanf(fp,"%d%d",k,n);printf("%d%d\n",k,n); fclose(fp);} 程序运行A.20 30B.20 50C.30 50D.30 20
有以下程序 include main( ) { FILE *fp; int i,k=0,n=0; fp=fopen(“d1.dat”, 有以下程序 #include <stdio.h> main( ) { FILE *fp; int i,k=0,n=0; fp=fopen(“d1.dat”,”w”); for(i=1;i<4;i++) fprintf(fp,”%d”,i); fclose(fp); fp=fopen(“d1.dat”,”r”); fscanf(fp,”%d%d”,k,n); printf(“%d %d\n”,k,n); fclose(fp);} 执行后输出结果是( )A.1 2B.123 0C.1 23D.0 0
有以下程序:includemain(){ FILE*fp;int i;char ch[]="abcd",t;fp=fopen("abc.dat","w 有以下程序: #include <stdio.h> main() { FILE *fp; int i; char ch[]="abcd",t; fp=fopen("abc.dat","wb+"); for(i=0;i<4;i++)fwrite(ch[i]1,1,fp); fseck(fp,-2L,SEEK_END) ; fread(t,1,1,fp); felose(fp); printf("%c\n",t); } 程序执行后的输出结果是( )。A.dB.cC.bD.a
有以下程序:includemain(){FILE *fp;int i,a[6]={1,2,3,4,5,6};fp=fopen("d2.dat","w" 有以下程序: #include<stdio.h> main() {FILE *fp;int i,a[6]={1,2,3,4,5,6}; fp=fopen("d2.dat","w"); fprintf(fp,"%d%d%d\n",a[0],a[1],a[2]); fprintf(fp,"%d%d%d\n",a[3],a[4],a[5]); fclose(fp); fp=fopen("d2.dat","r"); fscanf(fp,"%d%d\n",k,A.1 2B.1 4C.123 4D.123 456
若有以下程序 include int a[ ]={2,4,6,8}; main( ) { int i; int *p=a; for(i=0;i 若有以下程序#include <stdio.h>int a[ ]={2,4,6,8};main( ){ int i;int *p=a;for(i=0;i<4;i++) a[i]=*p;printf("%d\n",a[2]);}上面程序的输出结果是A.6B.8C.4D.2
有以下程序 include main( ) { FILE *fp;int i,a[6]={1,2,3,4,5,6}; fp=fopen("d3.da 有以下程序#include <stdio.h>main( ){ FILE *fp;int i,a[6]={1,2,3,4,5,6};fp=fopen("d3.dat","w+b");fwrite(a,sizeof(int),6,fp);fseek(fp,sizeof(int)*3,SEEK_SET);/*该语句使读文件的位置指针从文件头向后移动3个int型数据*/fread(a,sizeof(int),3,fp);fclose(fp);for(i=0;i<6;i++)printf("%d,",a[i]);}程序运行后的输出结果是A.4,5,6,4,5,6,B.1,2,3,4,5,6,C.4,5,6,1,2,3,D.6,5,4,3,2,1,
有以下程序: include main( ) { FILE *fp; int i=20,j=50,k,n; fp=fopen("d1.da 有以下程序: #include<stdi0.h> main( ) { FILE *fp; int i=20,j=50,k,n; fp=fopen("d1.dat","W"); fprintf(fp,"%d\n",i);fprintf(fp,"%d\n",j); fclose(fp); fp=fopen("d1.dat","r",); fscanf(fp,"%d%d",&k,&n); printf("%d%d\n",k,n); fclose(fp); } 程序运行后的输出结果是A.20 30B.20 50C.30 50D.30 20
有以下程序:include main(){FLLE *fp;int i=20,j=30,k,n;fp=fopen("d1.dat""w");fprin 有以下程序: #include <stdio.h> main() {FLLE *fp;int i=20,j=30,k,n; fp=fopen("d1.dat""w"); fprintf(fp,"%d\n",i);fprintf(fp,"%d\n",j); fclose(fp); fp=fopen("d1.dar","r"); fp=fscanf(fp,"%d%d",k,n); printf("%d%d\n",k,n); fclose(fp); ) 程序运行后的输出结果是( )。A.20 30B.20 50C.30 50D.30 20
单选题有以下程序:#include main(){ FILE *fp; int a[10]={1,2,3},i,n; fp=fopen(d1.dat,w); for(i=0;i3;i++) fprintf(fp,%d,a[i]); fprintf(fp,); fclose(fp); fp=fopen(d1.dat,r); fscanf(fp,%d,n); fclose(fp); printf(%d,n);}程序的运行结果是( )。A12300B123C1D321
单选题有以下程序:#include main(){ FILE *fp; int i,a[6]={1,2,3,4,5,6},k; fp=fopen(data.dat,w+b); fwrite(a[0],sizeof(int),1,fp); for(i = 1;i 6;i++) { fseek(fp,0L,0); fread(k,sizeof(int),1,fp); fseek(fp,0L,0); a[i]+=k; fwrite(a[i],sizeof(int),1,fp); } rewind(fp); fread(k,sizeof(int),1,fp); fclose(fp); printf(%d,k);}程序的运行结果是( )。A21B6C123456D11
单选题有以下程序#include main(){ int i; FILE* fp; for (i=0; i5;i++) { fp = fopen(output.txt, w); fputc('K'+ i, fp); fclose(fp); }}程序运行后,在当前目录下会生成一个output.txt文件,其内容是( )。AEBEOFCABCDEDA