C# 输入10个整数,要求输出其平均值、最大值、最小值,求代码、
来源:学生作业帮 编辑:灵鹊做题网作业帮 分类:综合作业 时间:2024/05/14 13:37:04
C# 输入10个整数,要求输出其平均值、最大值、最小值,求代码、
请用C#
请用C#
/* (程序头部注释开始)
* 输入描述:
* 问题描述:设计一个程序,输入10个数存入数组中,求最大值、最小值和平均值.
* 程序输出:
* 程序头部的注释结束
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int []num = new int [10];
Console.WriteLine("请输入十个数:");
for (int i = 0; i < 10; i++)
{
string s = Console.ReadLine();
int x = int.Parse(s);
num[i] = x;
}
int max = num[0];
for (int n = 1; n < 10; n++)
{
if(max < num[n])
max = num[n];
}
Console.WriteLine("最大值是{0}",max);
int min = num[0];
for (int a = 1; a < 10; a++)
{
if (min > num[a])
min = num[a];
}
Console.WriteLine("最小值是{0}",min);
int all = 0;
for (int h = 0; h < 10; h++)
{
all = all+ num[h];
}
double average = all / 10;
Console.WriteLine("平均值是{0}",average);
Console.ReadKey(false);
}
}
}
再问: thanks ,测试完ok马上就给分
* 输入描述:
* 问题描述:设计一个程序,输入10个数存入数组中,求最大值、最小值和平均值.
* 程序输出:
* 程序头部的注释结束
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int []num = new int [10];
Console.WriteLine("请输入十个数:");
for (int i = 0; i < 10; i++)
{
string s = Console.ReadLine();
int x = int.Parse(s);
num[i] = x;
}
int max = num[0];
for (int n = 1; n < 10; n++)
{
if(max < num[n])
max = num[n];
}
Console.WriteLine("最大值是{0}",max);
int min = num[0];
for (int a = 1; a < 10; a++)
{
if (min > num[a])
min = num[a];
}
Console.WriteLine("最小值是{0}",min);
int all = 0;
for (int h = 0; h < 10; h++)
{
all = all+ num[h];
}
double average = all / 10;
Console.WriteLine("平均值是{0}",average);
Console.ReadKey(false);
}
}
}
再问: thanks ,测试完ok马上就给分
C# 输入10个整数,要求输出其平均值、最大值、最小值,求代码、
输入3个整数,计算并输出其中的最大值和最小值.用c#完成
输入10个整数计算10个数的和 平均值 最大值和最小值
程序设计语言C.用循环语句.输入最多10个整数,找出最大值、最小值,并计算平均值.
输入一组整数,输出其中的最大值,最小值,和,平均值(两位小数),不能用数组
输入实数个数:n,并输入n个实数.输出:平均值、最大值、最小值.
C语言输入10个整数,输出大于等于其平均值的数的个数
任意输入10个数,求最大值、最小值、平均值
输入几个数,求最大值最小值平均值?
写出c程序:输入20个整数,求3个最大值和3个最小值,输出结果
定义一个整数数组a[10]并输入10个整数,输出其中的最大值、最小值及其所在的下标.
任意输入三个整数,求他们的和,平均值,最大值,最小值