-
-
Save turbotree/6898159 to your computer and use it in GitHub Desktop.
两个数字互换
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
java.util.Scanner input = new java.util.Scanner(System.in); | |
System.out.println("请输入数字A:"); | |
int numA = input.nextInt(); | |
System.out.println("请输入数字B:"); | |
int numB = input.nextInt(); | |
int temp = numA; | |
numA = numB; | |
numB = temp; | |
System.out.println("NumA :" + numA); | |
System.out.println("NumB :" + numB); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Test { | |
public static void main(String[] args) { | |
java.util.Scanner input = new java.util.Scanner(System.in); | |
System.out.println("请输入数字A:"); | |
int numA = input.nextInt(); | |
System.out.println("请输入数字B:"); | |
int numB = input.nextInt(); | |
numA = numA + numB; | |
numB = numA - numB; | |
numA = numA - numB; | |
System.out.println("NumA :" + numA); | |
System.out.println("NumB :" + numB); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment