本文實例講述了C#實現輸入10個數存入到數組中并求max和min及平均數的方法。分享給大家供大家參考,具體如下:
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();
}
}
}
PS:這里再為大家推薦幾款計算工具供大家進一步參考借鑒:
在線一元函數(方程)求解計算工具:
http://tools.html5code.net/jisuanqi/equ_jisuanqi
科學計算器在線使用_高級計算器在線計算:
http://tools.html5code.net/jisuanqi/jsqkexue
在線計算器_標準計算器:
http://tools.html5code.net/jisuanqi/jsq
更多關于C#相關內容還可查看本站專題:《C#字符串操作技巧總結》、《C#數據結構與算法教程》、《C#常見控件用法教程》、《WinForm控件用法總結》、《C#程序設計之線程使用技巧總結》、《C#數組操作技巧總結》及《C#面向對象程序設計入門教程》
希望本文所述對大家C#程序設計有所幫助。
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!