这篇文章主要介绍了C#实现输入10个数存入到数组中并求max和min及平均数的方法,涉及C#简单数据转换与数值运算相关操作技巧,需要的朋友可以参考下
这篇文章主要介绍了C#实现输入10个数存入到数组中并求max和min及平均数的方法,涉及C#简单数据转换与数值运算相关操作技巧,需要的朋友可以参考下
这篇文章主要介绍了C#实现输入10个数存入到数组中并求max和min及平均数的方法,涉及C#简单数据转换与数值运算相关操作技巧,需要的朋友可以参考下
本文实例讲述了C#实现输入10个数存入到数组中并求max和min及平均数的方法。分享给大家供大家参考,具体如下:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { static void Main(string[] args) { int nu1, max,min,number; int[] str = new int[10]; for (nu1 = 0; nu1<10; nu1++) str[nu1] = Int32.Parse(Console.ReadLine()); max = str[0]; min = str[1]; number = 0; for (nu1 = 0; nu1 < 10; nu1++) { number += str[nu1]; if (str[nu1] > max) max = str[nu1]; if (str[nu1] < min) min = str[nu1]; } number /= 10; Console.WriteLine("max is :{0}",max); Console.WriteLine("min is :{0}", min); Console.WriteLine("pingjun is :{0}", number); Console.ReadKey(); } }} |
希望本文所述对大家C#程序设计有所帮助。
发表评论