Skip to content

Instantly share code, notes, and snippets.

@fanker
Created September 20, 2012 12:11
Show Gist options
  • Save fanker/3755532 to your computer and use it in GitHub Desktop.
Save fanker/3755532 to your computer and use it in GitHub Desktop.
两数互换
public class Change{
public static void main(String[] args){
int a=5;
int b=7;
a=a+b;
b=a-b;
a=a-b;
System.out.println(a);
System.out.println(b);
}
}
public class Test{
public static void main(String[] args){
java.util.Scanner input=new java.util.Scanner(System.in);
System.out.println("请输入A的值:");
int A=input.nextInt();
System.out.println("请输入B的值:");
int B=input.nextInt();
int C=A;
A=B;
B=C;
System.out.println("输出A的值="+A);
System.out.println("输出B的值="+B);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment