zoukankan      html  css  js  c++  java
  • 最值、对应索引位置

     

                String[] names = { "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣" };
                int[] scores = { 89, 90, 98, 56, 60, 91, 93, 85 };
                int max = scores[0];
                int index=0;//记录最大值索引位置
                for (int i = 1; i < scores.Length; i++) {
                    if (max < scores[i]) {
                        max = scores[i];
                        index = i;
                    }
                }
                Console.WriteLine("最高分为:"+max);
                Console.WriteLine("姓名是:" + names[index]);
                Console.ReadKey();

     

                String[] names = { "吴松", "钱东宇", "伏晨", "陈陆", "周蕊", "林日鹏", "何昆", "关欣" };
                int[] scores = { 89, 90, 98, 56, 60, 91, 93, 85 };
                int index = 0;//记录满足要求的索引位置
                Console.WriteLine("及格的人是:");
                for (int i = 0; i < scores.Length; i++)
                {
                    if (scores[i]>=60)
                    {
                        index = i;
                        Console.Write(names[i]+" ");
                    }
                }          
                Console.ReadKey();
  • 相关阅读:
    jquery 插件扩展2
    jquery 插件扩展
    call apply bind
    bom object
    js oop 封装
    js oop 继承
    js页面之间传参2
    js弹出新窗口的6中方法
    display Tag
    js中extends方法
  • 原文地址:https://www.cnblogs.com/xixixing/p/9565188.html
Copyright © 2011-2022 走看看