C#编写程序,从键盘上输入10名学生的成绩,要求计算出这些学生成绩中的最高分数。

解决方案 »

  1.   

    int max = 0;
    string input = "";
    for (int i = 1; i <= 10; i++)
    {
        Console.WriteLine("Please input #{0}:", i);
        input = Console.ReadLine();
        if (Convert.ToInt32(input) > max)
        {
            max = Convert.ToInt32(input);
        }
    }
    Console.WriteLine(max.ToString());
      

  2.   

    static void Main(string[] args)
            {
                int max = int.MinValue, In = 0;
                for (int i = 0; i < 10; i++)
                {
                    In = Convert.ToInt32(Console.ReadLine());
                    if (max < In)
                        max = In;
                }
                Console.WriteLine(max.ToString());
            }
      

  3.   


    List<int> list = new List<int>();            for (int i = 0; i <= 10; i++)
                {
                    int num = Int32.Parse(Console.ReadLine());
                    list.Add(num);
                }
                
                Console.WriteLine("最高分是:"+list.Max());
      

  4.   

    decimal max=0;
    for (int i = 1; i <= 10; i++) 

        Console.WriteLine("{0}", i); 
        input = Console.ReadLine(); 
        if (decimal.TryParse(input,out max))
        { 
            max = decimal.Parse(input); 
        } 

    Console.WriteLine(max.ToString());
      

  5.   

    int max=0;
    int a=0;
    for(int i=0;i<10;i++)
    {
       console.WriteLine("请输入第{0}个数:",i);
       a=int.parse(console.ReadLine());
       if(a>max)
       {
         max=a;
       }
    }
    console.WriteLine(max);
    console.ReadLine();