double result = 0;
Console.Write("请选择一种运算:1、加法 2、减法 3、乘法 4、除 法"+"\n");
Console.Write("请选择算法:");
double a = Convert.ToInt32(Console.ReadLine ());
Console.WriteLine("请输入第一个数字:");
double b = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入第二个数字:");
double c = Convert.ToInt32(Console .ReadLine ());
if(a==1)
{
result = b + c;
}
if (a==2)
{
if(c>b)
{
double temp = 0;
temp = c;
c = b;
b = temp;
}
result = b- c;
}
if(a==3)
{
result = b * c;
}
if(a==4)
{
if(c>b)
{
double t = 0;
t = c;
c = b;
b = t;
}
result = b / c;
}
Console.WriteLine();
Console.WriteLine("*********运算结果是:{0}",result);
Console.ReadKey();
image.png
网友评论