坚持下去灬
2019-09-05 14:57
#include <stdio.h>
int i;
void replacemax(int arr[],int value)
{
int max=arr[0];
int index=0;
for(i=1;i<5;i++)
{
if(arr[i]>max)
{
max=arr[i];
index=i;
}
}
arr(index)=value;
}
int main()
{
int arr1[] = {10,41,3,12,22};
int arr2[] = {1,2,3,4,5};
replacemax(arr1,arr2[0]);
for(i=0;i<5;i++)
{
printf("%d",arr1[i]);
}
return 0;
}
输出的结果是:
hello.c: In function 'replaceMax': hello.c:15:5: error: called object 'arr' is not a function or function pointer arr(index)=value; ^~~ hello.c:3:21: note: declared here void replaceMax(int arr[],int value)
arr(index)=value;
arr[index]=value;
C语言入门
926210 学习 · 20797 问题
相似问题