public static void swap(int x,int y)
{
int temp=x;
x=y;
y=temp;
}上面这个是用java描述的算法,我不理解问题的意思,
我又写了这个,就可以运行了,public class swap {
public static void main(String[] args)
{
int x,y,temp;
x=Integer.parseInt(args[0]);
y=Integer.parseInt(args[1]);
temp=x;
x=y;
y=temp;
System.out.println("x="+x+"\n"+"y="+y+"\n");
}
}
{
int temp=x;
x=y;
y=temp;
}上面这个是用java描述的算法,我不理解问题的意思,
我又写了这个,就可以运行了,public class swap {
public static void main(String[] args)
{
int x,y,temp;
x=Integer.parseInt(args[0]);
y=Integer.parseInt(args[1]);
temp=x;
x=y;
y=temp;
System.out.println("x="+x+"\n"+"y="+y+"\n");
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货