第十三次作业

代码

namespace 第十三次作业第一题
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请选择你要的运算:1.加法 2.减法 3.乘法 4.除法");
int yun = Convert.ToInt32(Console.ReadLine());
int[] shu = new int[2];
for (int i = 0; i < shu.Length; i++)
{
Console.Write("请输入第{0}个数字:",i+1);
shu[i] = Convert.ToInt32(Console.ReadLine());
}
if (yun == 1)
{
Console.Write("运算结果为{0}", jia(shu));
}
else if (yun == 2)
{
Console.Write("运算结果为{0}", jian(shu));
}
else if (yun == 3)
{
Console.Write("运算结果为{0}", cheng(shu));
}
else if (yun == 4)
{
Console.Write("运算结果为{0}", chu(shu));
}
Console.ReadKey();
}
static double jia (int[] arr)
{
double sum = 0;
double num = 0;
for (int i = 0; i <1; i++)
{
sum += arr[i];
num += arr[i + 1];
}
return num + sum;
}
static double jian(int[] arr)
{
double sum = 0;
double num = 0;
for (int i = 0; i < 1; i++)
{
sum += arr[i];
num += arr[i+1];
}
return sum - num;
}
static double cheng(int[] arr)
{
double sum = 0;
double num = 0;
for (int i = 0; i < 1; i++)
{
sum += arr[i];
num += arr[i + 1];
}
return sum * num;
}
static double chu(int[] arr)
{
double sum = 0;
double num = 0;
for (int i = 0; i < 1; i++)
{
sum += arr[i];
num += arr[i + 1];
}
return sum / num;
}
}
}

效果
第十三次作业_第1张图片
QQ图片20181226172529.png

你可能感兴趣的:(第十三次作业)