快捷导航

为什么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)
            {
                j++;
                max = score;
            }
        }
        Console.Write("分数最高的是{0},分数是{1},",name[j],max);
            
        }
    }
}

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员1

"=" 是 赋值符号,而不是 数学中 相等的意思,
max = j = -1 :
将 -1 的值 先赋值给 j,这是 j 的 对应的 值为 -1
然后再将 j 的值 赋值给 max,这是 max 的值 为 变量 j 所对应的 值 -1
由于 max,j 都是 int 类型 的 变量 所以 max = j = -1 是没有问题的
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP