#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int Find_Bigest(int *arr,int n)
{
int i, j;
int tmp = 0;
for (i = 0;i < n;i++)
{
if (arr[i] > arr[tmp])
{
tmp = i;
}
}
return tmp;
}
int main()
{
int a = 0;
printf(“please input the number of global: “);
scanf(”%d”,&a);
int arr[100] = { 0 };
for (int i = 0;i < a;i++)
{
scanf("%d", &arr[i]);
}
int answer=Find_Bigest(arr,a);
printf(“the most of number is : %d\n it’s subscript is: %d\n”,arr[answer], answer);
system(“pause”);
return 0;
}
the most number of an arr and it's subscript
最新推荐文章于 2024-10-25 22:38:04 发布
本文介绍了一个使用C语言实现的查找数组中最大值的算法。通过定义一个Find_Bigest函数,该函数接收一个整型数组及其长度作为参数,遍历整个数组找到并返回最大值的下标。在主函数中,用户输入全局变量数量和具体数值,调用Find_Bigest函数获取最大值及其下标,并输出结果。
1万+

被折叠的 条评论
为什么被折叠?



