数组练习

 //输入十个人的分数,求最高分最低分平均分

                int[] fenshu = new int[10];
                int max = 0;
                int min = 0;
                int sum = 0;

                 
                for (int i = 0; i < 10; i++)
                {
                    fenshu[i] = int.Parse(Console.ReadLine());
                    sum += fenshu[i];
                if(i==0)
                {
                    max = fenshu[i];
                    min = fenshu[i];
                }
                else { 
                    if(max<fenshu[i])
                    {
                        max = fenshu[i];
                    }
                    if (min > fenshu[i])
                    {
                        min = fenshu[i];
                              
                    }
                    }
                }
                Console.WriteLine("最高分" + max);
                Console.WriteLine("最低分" + min);
                Console.WriteLine("平均分" + sum/10);

            Console.ReadLine();

  

posted @ 2015-11-23 11:05  小菜鸟。  阅读(128)  评论(0编辑  收藏  举报