下面程序以每行4个数的形式输出a数组,请分析程序填空。#defineN20main(){inta[N],i;for(i=0;i①);for(i=0;i{printf("%3d",a[i]);if(②)printf("\n");}}
调用fun函数求5行5列矩阵所有元素之和。编写fun函数。#include#defineM5intfun(inta[M][M]){/**********Program**********//**********End**********/}main(){inta[M][M]={{1,3,5,7,9},{2,4,6,8,10},{2,3,4,5,6},{4,5,6,7,8},{1,3,4,5,6}};intsum;sum=fun(a);printf("s=%d\n",sum);}
调用fun函数求5行5列矩阵主对角线元素之和。#include#defineM5intfun(inta[M][M]){/**********Program**********//**********End**********/}main(){inta[M][M]={{1,3,5,7,9},{2,4,6,8,10},{2,3,4,5,6},{4,5,6,7,8},{1,3,4,5,6}};intsum;sum=fun(a);printf("s=%d\n",sum);}
从键盘输入一个字符串放在字符数组ss中,假设ss的大小是30,求输入的字符串中字符为'a'的个数。#includeint fun(char ss[]){}main(){char ss[30];int i,n;gets(ss);n=fun(ss) ;printf("%d\n",n);}