zoukankan      html  css  js  c++  java
  • 数组及其简单应用

    数组的模式:

                int[] a = new int[10];//开辟一个空间给a

                string[] b=new string[20];//

                数组元素的引用            

    例:             数组名【下标】  下标从0开始            

                  a[0] = 10;            

                  a[1] = 20;            

                  a[3] = 30;

                  Console.Write(a[2]);            

    调用             int[] a = new int[10];            

                       for (int i = 0; i < a.Length; i++)            

                       {                

                            a[i] = (i + 1) * 10;            

                       }            

                       Console.WriteLine("");

    简单使用(教练给球员打分):

                int[] qy = new int[10];
                for (int i = 0; i < 10; i++)
                {
                    Console.Write("请给第{0}个球员打分:",i+1);
                    qy[i] = Convert.ToInt32(Console.ReadLine());
                }
                for (int i = 0; i < 10; i++)
                {
                    Console.WriteLine ("第{0}号球员的得分为:{1}",i+1,qy[i]);
                }
                //找出最高分和最低分
                int max=0,min=1000;
                int max_no=0,min_no=0;
                for(int i=0;i<10;i++)
                {
                if(qy[i]>max)
                {
                max=qy[i];
                    max_no=i;
                }
                    if(qy[i]<min)
                    {
                    min=qy[i];
                        min_no=i;
                    }
                    Console.WriteLine("");
                }

  • 相关阅读:
    codeforces 985 F. Isomorphic Strings
    Educational Codeforces Round 44
    codeforces 979D
    ARC060 Digit Sum II
    Iroha and Haiku II
    Unhappy Hacking II
    Just h-index 2018湘潭邀请赛
    [HAOI2007]理想的正方形
    P1231 教辅的组成
    最小割数学形式
  • 原文地址:https://www.cnblogs.com/UC0079/p/5491765.html
Copyright © 2011-2022 走看看