#include
#define SIZE 5
int Getmax(int *ac,int n)
{
int i,max;
for(i=0;i<=2;i++)
{
max = (ac[i]>ac[i+1]?ac[i]:ac[i+1]);
max =(max>ac[i+2]?max:ac[i+2]);
}
return max;
}
int Getmin(int *ar,int m)
{
int i,min;
for(i=0;i<=2;i++)
{
min = (ar[i]>ar[i+1]?ar[i+1]:ar[i]);
min =(min>ar[i+2]?ar[i+2]:min);
}
return min;
}
int main(void)
{
int a[SIZE],temp1,temp2,i,a;
printf("請輸入5個范圍在10000以內的整數:");
for(i=0;i<=4;i++)
{
scanf("%d",&a[i]);
}
temp1=Getmin(a,SIZE);
temp2=Getmax(a,SIZE);
printf("max=%d,min=%d",temp2,temp1);
}
error C2040: 'a' : 'int ' differs in levels of indirection from 'int [5]'
你定義了2個變量,一個數組一個整數都叫a
換個名字