//调用函数 先定义函数 再使用 #include<stdio.h>//定义函数 voidya(void);voidin(void);intmain(){//调用函数 ya();in();ya();}//被调用的函数 voidin(void){printf("How do you do?\n");}voidya(void){printf("****************\n");}
#include<stdio.h>intmain(){floataverage(float a[10]);float a[10];int i;float b;printf("Please input number:");for(i=0;i<10;i++){scanf("%f",&a[i]);}
b=average(a);//调用函数时,函数()里面时数组名 printf("the average of number is:%f",b);}floataverage(float a[10])//需要定义函数()内部的数组,说明类型 {float sum=0;int i;for(i=0;i<10;i++){
sum=sum+a[i];}float ave;
ave=(float)sum/10.0;return(ave);}
#include<stdio.h>intmain(){float average (float array[],int N);float a[5]={98.5,97,91.5,60,55};float b[10]={67.5,89.5,99,69.5,77,89.5,76.5,54,60,99.5};printf("the average of number is:%f\n",average(a,5));printf("the average of number is:%f",average(b,10));}float average (float array[],int N){int i;float aver,sum=0;for(i=0;i<N;i++){
sum=sum+array[i];}
aver=sum/N;return(aver);}
#include<stdio.h>intmax();intmain(){int a[3][4];int i,j,m;printf("Please input number:");for(i=0;i<3;i++){for(j=0;j<4;j++){scanf("%d",&a[i][j]);}}
m=max(3,4,a);printf("the max of those number is%d",m);return0;}intmax(int i,int j,int a[i][j]){int mx;
mx=a[0][0];for(i=0;i<3;i++)for(j=0;j<4;j++){if(a[i][j]>mx)
mx=a[i][j];}return(mx);}