1、已知a,b均是整型变量,写出将a,b两个变量中的值互换的程序。(知识点:变量和 运算符综合应用)
package first;
public class one {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a=1;
int b=2;
int c=a;
a=b;
b=c;
System.out.println("交换后a的值:"+a);
System.out.println("交换后b的值:"+b);
}
package
dome1;
import
java.util.Scanner;
public
class
Abc {
public
static
void
main(String[] args) {
Scanner scan =
new
Scanner(System.in);
int
a=scan.nextInt();
int
ge=a%
10
;
int
shi=a/
10
%
10
;
int
bai=a/
100
;
int
sum=ge+shi+bai;
System.out.println(
"ge="
+ge);
System.out.println(
"shi="
+shi);
System.out.println(
"bai="
+bai);
System.out.println(
"sum="
+sum);
}
}
package first;
public class one {
public static void main(String[] args) {
// TODO Auto-generated method stub
//定义一个华氏度
int a=50;
//定义一个摄氏度
int b=(a-32)*5/9;
System.out.println("摄氏度="+b);
}
}
package first;
public class one {
public static void main(String[] args) {
// TODO Auto-generated method stub
char a = 'A';
System.out.println((char)(a + 32));
}
}