#include<stdio.h> long fun(int n) {long s; if(n<=2)s=2; else s=n+fun(n-1); printf("%d\t",s); return s; } main() { fun(7) printf("\n"); }
查看答案
为二维数组各元素输入数据,计算并输出全部元素之和。 #define M 5 void main() { int i,j,a[M][M],sum=______; /*第一空*/ for(______) /*第二空*/ for(j=0;j<M;j++) { scanf("%d",&a[i][j]); sum+=______; /*第三空*/ } printf("sum=%d\n",sum); }
二进制文件中数据都是按其______方式存放的,文本文件中数据都是将其转换成对应的______来存放。
C盘中p1.c.txt文件的内容为:abcde。A盘中p1.c.txt为空文档。 #include<stdio.h> #include<stdib.h> main() {FILE *f1 *f2; int k; if((f1=fopen("C:\\p1.c.txt","r"))==NULL) {printf("can not open file!\n"); exit(0); } if((f2=fopen("A:\\p1.c.txt","w"))==NULL) {printf("can not open file!\n"); exit(0); } for(k=1;k<=500;k++) {if(feof(f1))break; fputc(fgetc(f1),f2); } fclose(f1); fclose(f2); } 以上程序的功能是______。
C语言早期规定可以采用两种方式建立文件缓冲区:______、______。