第三章:程序控制语句
1.从小打到排序数值
import java.util.Scanner;public class NewTest {// 1.从小打到排序数值public static void main(String[] args) {Scanner s = new Scanner(System.in);System.out.println("请输入3个整数:");int a = s.nextInt();int b = s.nextInt();int c = s.nextInt();if (a < b) {int t = a;a = b;b = t;}if (a < c) {int t = a;a = c;c = t;}if (b < c) {int t = b;b = c;c = t;}System.out.println("从大到小的顺序输出:");System.out.println(a + "," + b + "," + c);s.close();}}
2.运算符
import java.util.Scanner;public class NewTest {public static void main(String[] args) {int x = 23;int y = 2;float z = 16.28f;System.out.println("x+y: " + (x + y));System.out.println("x-y: " + (x - y));System.out.println("x*y: " + x * y);System.out.println("x/y: " + x / y);System.out.println("x%y: " + x % y);System.out.println("x=" + x + "," + "y=" + y);System.out.println('a' == 98);System.out.println('a' > 'b');System.out.println("x>y:" + (x > y));}
}