为什么max=j=-1

using System;

using System.Collections.Generic;

using System.Text;


namespace projGetMaxScore

{

    class Program

    {

        static void Main(string[] args)

        {

             int j,max;

             max = j = -1;

        int[] score=new int[8]{89,90,98,56,60,91,93,85};

            string[] name=new string[8]{"吴松","铁东宁","伏晨","陈陆","周蕊","林日鹏","何昆","关欣"};//申明姓名数组

        for (int i = 0; i < 8;i++ )

        {

            if (max < score[i])

            {

                j++;

                max = score[i];

            }

        }

        Console.Write("分数最高的是{0},分数是{1},",name[j],max);

            

        }

    }

}


边防连
浏览 1597回答 1
1回答

慕婉清0_郁乱我心

"=" 是 赋值符号,而不是 数学中  相等的意思 ,max = j = -1  :                        将 -1 的值 先赋值给 j,这是 j 的 对应的 值为 -1                     然后再将 j 的值 赋值给 max,这是 max 的值 为 变量 j 所对应的 值 -1                        由于 max,j 都是 int 类型 的 变量 所以 max = j = -1  是没有问题的
打开App,查看更多内容
随时随地看视频慕课网APP