单选题有以下程序#include main(){ FILE *fp; int k,n,a[6]={1,2,3,4,5,6}; fp=fopen(d2.dat,w); fprintf(fp,%d%d%d,a[0],a[1],a[2]); fprintf(fp,%d%d%d,a[3],a[4],a[5]); fclose(fp); fp=fopen(d2.dat,r); fscanf(fp,%d%d,k,n); printf(%d%d,k,n); fclose(fp);}程序运行后的输出结果是( )。A123456B14C1234D12
单选题
有以下程序#include main(){ FILE *fp; int k,n,a[6]={1,2,3,4,5,6}; fp=fopen(d2.dat,w); fprintf(fp,%d%d%d,a[0],a[1],a[2]); fprintf(fp,%d%d%d,a[3],a[4],a[5]); fclose(fp); fp=fopen(d2.dat,r); fscanf(fp,%d%d,&k,&n); printf(%d%d,k,n); fclose(fp);}程序运行后的输出结果是( )。
A
123456
B
14
C
1234
D
12
参考解析
解析:
将有6个元素的整型数组分两行输出到一个文件中,因为输出的都是数字并且每行都没有分隔符,所以当再对其进行读取操作时,每一行都会被认为是一个完整的数,而换行符则作为它们的分隔符。答案选择A选项。
将有6个元素的整型数组分两行输出到一个文件中,因为输出的都是数字并且每行都没有分隔符,所以当再对其进行读取操作时,每一行都会被认为是一个完整的数,而换行符则作为它们的分隔符。答案选择A选项。
相关考题:
有以下程序#include stdio.hmain( ){ 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.dat", " 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 k,n,a[6]={1,2,3,4,5,6}; fp=fopen(“d2.dat”,”w”); fprintf(fp,”%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”,k,n); printf(“%d%d\n”,k,n); fclose(fp); } 程序运行后的输出结果是( )。A.1 2B.1 4C.123 4D.123 456
有以下程序includemain(){FILE*fp;int k,n,a[6]={1,2,3,4,5,6};fp=fopen("d2.dat","w" 有以下程序 #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.dat","r"); fscanf(fp,"%d%d",k,nA.1 2B.1 4C.123 4D.123 456
有以下程序 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
有以下程序: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 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 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 i=20,j=30,k,n;fp=fopen(“d1.dat”,“w”);fprintf 有以下程序 #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
有以下程序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
有以下程序 include main() { FILE*fp;int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i 有以下程序 #include<stdio.h> main() { FILE*fp;int i,k=0,n=0; fp=fopen("d1.dat","w"); for(i=1;1<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 2 3D.1 23
有以下程序: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
有以下程序: #includestdiO.h main( ) { FILE*fp; int k,n,i,a[6]={1,2,3,4,5,6}; fp=fopen("d2.dat","w"); for(i=0;i6;i++) fprintf(fp,"%d\n",a[i]); fclose(fp); fp(i=0;i3;i++) fscanf(fp,"%d%d",k,n); fclose(fp); printf("%d\n,%d\n,k,n); } 程序运行后的输出结果是( )。A.1, 2B.3,4C.5,6D.123,456
有以下程序:include main(){FILE *fp;int i,k=0, n=0; fp=fopen("d1.dat","w"); for(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
有以下程序#includestdio.hmain(){ FILE,*fp;int k,n,i,a[6]={1,2,3,4,5,6};fp=fopen("d2.dat","W");for(i=0;i6;i++) fprintf(fp,"%d\n",a[i]);fclose(fp);fp=fopen("d2.dat","r");for(i=0;i3;i++) fscanf(fp,"%d%d",k,n);fclose(fp);printf("%d,%d\n",k,n);}程序运行后的输出结果是A.1,2B.3,4C.5,6D.123,456
有以下程序: 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
有以下程序#includestdio.hmain(){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.dat","r");fscanf(fp,"%d%d",k,n);printf("%d%d\n",k,n);fclose(fp);}程序运行后的输出结果是A.1 2B.1 4C.123 4D.123 456
有以下程序includemain(){FILE *fP;int k,n,a[6]={1,2,3,4,5,6}; fp=fopen ("d2.dat", 有以下程序 #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.dat","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(){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
有以下程序includemain(){ 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"); fscanf(fp,"%d%d",k,n;printf("%d%d\n",k,n); fclose(fp);} 程序运行后的输出结果是A.20 30B.20 50C.30 50D.30 20
试题40有以下程序#include stdio.hmain(){FILE *fp;int k, n, i, a[6]={1,2,3,4,5,6};fp=fopen(“d2.dat”, “w”);for(i=0; i6; i++) fprintf(fp, “%d\n“,a[i]);fclose(fp);for(i=0; i3; i++) fscanf(fp, “%d%d”, k,n);fclose(fp);printf(“%d,%d\n”, k, n);}程序运行后的输出结果是()A.1,2B.3,4C.5,6D.123,456
单选题有以下程序:#include main(){ FILE *fp; int k,n,i,a[6]={1,2,3,4,5,6}; fp=fopen(d2.dat,w); for(i=0;i6;i++) fprintf(fp,%d,a[i]); fclose(fp); fp=fopen(d2.dat,r); for(i=0;i3;i++) fscanf(fp,%d%d,k,n); fclose(fp); printf(%d,%d,k,n);}程序运行后的输出结果是( )。A1,2B3,4C5,6D123,456