您的位置:首页 > 其它

1112 -- 简单数据统计

2015-08-30 10:22 239 查看
简单数据统计
Time Limit:1000MS Memory Limit:65536K

Total Submit:254 Accepted:170
Description
输入若干个整数求出他们的最小值,最大值,平均值(保留三位有效数字)输入保证这些数都不超过1000的正整数

Input
输入若干个整数

Output
求出他们的最小值,最大值,平均值(保留三位有效数字)

Sample Input
2 8 3 5 1 7 3 6

Sample Output
1 8 4.375

Source
lrj程序入门

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace AK1112 {
class Program {
static void Main(string[] args) {
string[] s = Regex.Split(Console.In.ReadToEnd().Trim(), @"\s+");//what's a fuck!!!
int[] a = new int[1005];
int max = int.Parse(s[0]), min = int.Parse(s[0]);
int sum = int.Parse(s[0]);
for (int i = 1; i < s.Length; i++) {
a[i] = int.Parse(s[i]);
if (a[i] > max) max = a[i];
if (a[i] < min) min = a[i];
sum += a[i];
}
double jt = sum * 1.0 / s.Length;
Console.WriteLine("{0} {1} {2}", min, max, jt.ToString("0.000"));
//Console.ReadKey();
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: