用C# 编写一个控制台应用程序,从键盘上输入3个数,输出这3个数的平均数. 5
展开全部
你试试 这个
public class AverageNum
{
public static void Main(String[] args)
{
int num1;
int num2;
int num3;
int sum;
int avernum;
Console.Write(" Enter First integer: ");
num1 = Convert.ToInt32(Console.ReadLine());
Console.Write(" Enter Second integer: ");
num2 = Convert.ToInt32(Console.ReadLine());
Console.Write(" Enter Three integer: ");
num3 = Convert.ToInt32(Console.ReadLine());
sum = num1 + num2 + num3;
avernum = sum / 3;
Console.WriteLine("Average is {0}", avernum);
}
}
public class AverageNum
{
public static void Main(String[] args)
{
int num1;
int num2;
int num3;
int sum;
int avernum;
Console.Write(" Enter First integer: ");
num1 = Convert.ToInt32(Console.ReadLine());
Console.Write(" Enter Second integer: ");
num2 = Convert.ToInt32(Console.ReadLine());
Console.Write(" Enter Three integer: ");
num3 = Convert.ToInt32(Console.ReadLine());
sum = num1 + num2 + num3;
avernum = sum / 3;
Console.WriteLine("Average is {0}", avernum);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询