public class LianXi { public static void main(String[] args) { int a=2; int b=5; int c; c=a; a=b; b=c; System.out.println("a="+a+" b="+b); } }
2.给定一个0~1000的整数,求各位数的和
public class Lian2 { public static void main(String[] args) { int a=233; int b, c, d,e; b = a / 100 % 10; c = a / 10 % 10; d = a % 10; e= b +c +d; System.out.println("结果为" + e); } }
3.华氏度50转成摄氏度
public class Lian2 { public static void main(String[] args) { int f=50; int c; c=(f-32)*5/9; System.out.println("摄氏度为" + c); } }
4、给定一个任意的大写字母A~Z,转换为小写字母。 (知识点:变量和运算符)
public class Lian2 { public static void main(String[] args) { char a = 'A'; System.out.println((char)(a + 32)); } }