#include
void main()
{
int i,n,k=0,max,a[10];
printf("输入正整数n(n大于1且不大于10): ");
scanf("%d",&n);
printf("输入%d个整数: ",n);
scanf("%d",&a[0]);
max=a[0];
for(i=1;i{
scanf("%d",&a[i]);
if(max{max=a[i];k=i;}
}
printf("最大值: %d\n对应的下标: %d",max,k);
}
//复制一下代码到编辑器运行,请采纳哦!
#include
#include
int main(){
int n = 0, *a, i=0, m=0,r;
while (n <= 1 || n > 10) {
printf("%s","请输入数组个数n[1<= n <10]:");
scanf("%d",&n);
};
a = (int*)malloc(sizeof(int) * n);
while(i
}
i = 0;
while(i
m = *(a+(i-1));
r = i - 1;
}
}
printf("%s","最大值为:");
printf("%d",m);
printf("%s",",最大值数组下标为:");
printf("%d",r);
printf("\n");
}
#include
int main()
{int n,i,a[10],maxi=0;
scanf("%d",&n);
for(i=0;i{scanf("%d",&a[i]);
if(a[i]>a[maxi])maxi=i;
}
printf("最大数%d是第%d个\n",a[maxi],maxi+1);
return 0;
}
#include
int main()
{
int n,i;
int max,p;
int a[10];
printf("请输入n的值\n");
scanf("%d",&n);
printf("请输入%d个整数\n",n);
for(i=0;i{
scanf("%d",&a[i]);
}
max=a[0];
p=0;
for(i=1;i{
if(max {
max=a[i];
p=i;
}
}
printf("最大的数是%d它的下标是%d",max,p);
return 0;
}
#include
#include
#include
int main()
{
int *a,i=0,n=0,big=0,xb=0;
scanf("%d",&n);
a=(int*)malloc(sizeof(int)*n);
memset(a,0,sizeof(int)*n);
for (i=0;i{
scanf("%d",&a[i]);
if (i==0)
{
big = a[i];
}else if (big {
big = a[i];
xb = i;
}
}
printf("big[%d]=[%d],",xb,big);
}
5
1
3
4
2
5
big[4]=[5],Press any key to continue