求数组int a[] = {4,-1,9,10,23},最大值,并得到对应index
2022/2/12 23:48:12
本文主要是介绍求数组int a[] = {4,-1,9,10,23},最大值,并得到对应index,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
//求数组int a[] = {4,-1,9,10,23},最大值,并得到对应index public class test{ public static void main(String[] args) { int a[] = {4,-1,9,10,23},temp = 0 ,index = 0; for (int i = 0; i <= 3;i++){ if (a[i] < a[i+1]){ temp = a[i+1]; index = i + 1; } } System.out.print("该数组最大值 = " + temp + "\n该数组最大值的下标 = " + index); }; }
这篇关于求数组int a[] = {4,-1,9,10,23},最大值,并得到对应index的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-29DataGrip使用ssh连接数据库的操作流程
- 2024-05-28SpringBoot3.2更新声明!
- 2024-05-28中外程序员到底有啥区别?
- 2024-05-25外企也半夜发布上线吗?
- 2024-05-24鸿蒙原生应用再新丁!芒果TV 入局鸿蒙
- 2024-05-22基本概念
- 2024-05-22检索数据
- 2024-05-22排序数据
- 2024-05-22基础过滤数据
- 2024-05-22通过逻辑操作符过滤数据