以下程序是求矩阵a和b的和,结果存入矩阵c中,并按矩阵形式输出。 #include<stdio.h> main() {int a[3][4]={{3,-2,1,5},{1,0,4,-3},{6,8,0,2}}; int b[3][4]={{-2,0,1,4},{5,-1,7,6},{6,8,0,2}}; int I,j,c[3][4]; for(______) /*第一空*/ for(______) /*第二空*/ c[i][j]=______;/*第三空*/ for(i=0;i<3;i++) {for(j=0;j<4;j++) printf("%3d",c[i||j]); } }
查看答案
以下函数的功能是从名为"filea.dat"的文本文件中逐个读入字符并显示在屏幕上。 #include<stdio.h> main() {FILE *fp;char ch; fp=fopen("filea.dat","r"); ______; /*第一空*/ while(______(fp));{putchar(ch);ch=______;}/*第二、三空*/ putchar(’\n’);fclose(fp); }
采用递归调用的算法编写一个计算x的n次方的函数(主函数调用省略)。
下列函数的主要功能是在w指向的数组的前*n个数据中插入x,要求w指向的数组的前*n个数据按由小到大顺序存放。插入x后,该数组中的数据仍按照从小到大的顺序排列,同时将*n修改为插入x后的长度。 void f(char *w,char x,int *n) {int i,p=0; w[*n]=x; while(x>w[p])______; /*第一空*/ for(i=*n;i>p;i--)w[i]=______;/*第二空*/ w[p]=x; ______; /*第三空*/ }
struct stu {int num; char name[10]; int age }; void py(struct stu *p) {printf("%s\n",(*p).name);} main() {struct stu student[3]={{1001,"Sun",25}, {1002,"Ling",23}, {1003,"Shen",22}}; py(student+1); }