
//import java.net.SocketTime
import java.util.Scanner;
//欢迎光临腾讯互联会员系统
//小孩子搬桌
//买车
//迷你计算器
//机票打折
//银行利率表
//电话传递数据
//定义三个整型变量a、b、c,他们的初始值分别为4、15、20。对表达式进行运算(算术运算符)。
//强制转换
//1.判断是奇数还是偶数
//2.根据成绩输出对应的等级,使用if多分支和switch语句分别实现。
//圆的半径
//每位数字都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换
public class day05 {
public static void main(String[] args) {
//创建对象
Scanner sc = new Scanner(System.in);
System.out.print("请输入一个4位正整数:");
int positiventegerI= sc.nextInt();
//分别求出4位整数个位,十位,百位,千位上的数
int Bit = positiventegerI % 10; //个位
int Ten = positiventegerI /10 % 10; //十位
int Hundredth = positiventegerI /100 %10; //百位
int ThousandBit = positiventegerI /1000; //千位
//加密
Bit = (Bit +5)%10; //个位加密
Ten = (Ten+ 5)%10; //十位加密
Hundredth = (Hundredth+ 5)%10; //百位加密
ThousandBit = (ThousandBit+ 5)%10; //千位加密
//个位和千位换位
int a = Bit;
Bit = ThousandBit;
ThousandBit=a;
//十位和百位换位1234
int b = Ten;
Ten = Hundredth;
Hundredth = b;
//整合
int encryption = ThousandBit*1000 + Hundredth*100 + Ten*10 + Bit;
//输出
System.out.print(encryption);
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)