0
0000
Unregistered / Unconfirmed
GUEST, unregistred user!
请大家帮忙看看这段C#代码!运行结果和预期不一样。谢谢帮忙!谢谢!
using System;
class swap
{
public void swapNum(int a ,int b)
{
a=a+b;
b=a-b;
a=a-b;
}
}
class building
{
private static swap swapab;
public static void Main()
{
swapab = new swap();
int x;
int y;
x=Convert.ToInt32(Console.ReadLine());
y=Convert.ToInt32(Console.ReadLine());
swapab.swapNum(x,y);
Console.WriteLine("x="+x);
Console.WriteLine("y="+y);
Console.ReadLine();
}
}
using System;
class swap
{
public void swapNum(int a ,int b)
{
a=a+b;
b=a-b;
a=a-b;
}
}
class building
{
private static swap swapab;
public static void Main()
{
swapab = new swap();
int x;
int y;
x=Convert.ToInt32(Console.ReadLine());
y=Convert.ToInt32(Console.ReadLine());
swapab.swapNum(x,y);
Console.WriteLine("x="+x);
Console.WriteLine("y="+y);
Console.ReadLine();
}
}