-
Notifications
You must be signed in to change notification settings - Fork 0
/
变长数组.c
48 lines (48 loc) · 804 Bytes
/
变长数组.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<stdio.h>
#include<stdlib.h>
double ave1(double *a){
double ave1=0;
int i;
for ( i = 0; i < 5; i++)
{
ave1+=a[i];
}
ave1/=5;
return ave1;
}
double ave2(double *a){
double ave2=0;
int i;
for ( i = 0; i < 15; i++)
{
ave2+=a[i];
}
ave2/=15;
return ave2;
}
double max(double *a){
double max=a[0];
int i;
for ( i = 0; i < 15; i++)
{
if(a[i]>max){
max=a[i];
}
}
return max;
}
int main(){
int n;
scanf("%d",&n);
double arr[n][5];
int i,t;
for(i=0;i<n;i++){
for(t=0;t<5;t++){
scanf("%lf",&arr[i][t]);
}
}
for(i=0;i<n;i++){
printf("%lf\n",ave1(arr[i]));
}
printf("%lf,%lf\n",ave2(arr),max(arr));
}