using System;//形成一个简单的加减乘除整数计算器
public class Ad {
public int Add(int x1,int x2) {
int sum;
sum = x1 + x2;
return sum;
}
}
public class Subtra
{
public int Sub(int x1, int x2)//这里返回值类型要注明
{
int sum;
sum = x1 - x2;
return sum;
}
}
public class Multiply
{
public int Mul(int x1, int x2)//这里返回值类型要注明
{
int sum;
sum = x1* x2;
return sum;
}
}
public class Divide
{
public double Div(int x1, int x2)//这里返回值类型要注明
{
double sum;
sum = x1*1.0 / x2;
return sum;
}
}
public class Program {
static void Main() {
int x = Convert.ToInt32(Console.ReadLine());
int y = Convert.ToInt32(Console.ReadLine());
/*console.ReadLine获取的是x的ascii值,所以如果想获得数值,需要convert转换为32位带符号整数*/
Console.Write($"{x},{y}\n");
Ad link1= new Ad();
int sumi=link1.Add(x,y);
/*调用方法中的函数及link1中的Add,Ad类就不需要再提及了*/
Console.WriteLine($"{sumi}");
Subtra link2 = new Subtra();
int subi = link2.Sub(x, y);
Console.WriteLine($"{subi}");
Multiply link3 = new Multiply();
int muli = link3.Mul(x, y);
Console.WriteLine($"{muli}");
Divide link4 = new Divide();
double divi = link4.Div(x, y);
Console.WriteLine($"{divi}");
}
}