问答详情
源自:6-6 通过接收用户输入优化练习

为什么出不来值呢

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] name = new string[5];
            int[] score = new int[5];
            for(int i=0;i<name.Length;i++)
            {
                name[i]=Console.ReadLine();
                score[i] = int.Parse (Console.ReadLine());
            }
            int sum = 0, avg;
            foreach(int a in score)
            {
                sum += a;
            }
            avg = sum / 5;
            Console.WriteLine("总分是{0},平均分是{1}", sum, avg);


        }
    }
    }


提问者:如清风明月呀 2018-09-06 16:47

个回答

  • qq_空灵_12
    2018-09-06 21:35:05

     int sum = 0, avg;

    这里错了