import java.util.*;
public class text14
{
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int num=0,one;
do
{
System.out.print("請輸入一個8位正整數:");
num = s.nextInt();
}
while (num<10000000||num>99999999);
int a[]=new int[8]; //8位數字
a[0] = num/10000000; //取千萬位的數字
a[1] = (num/1000000)%10;//取百萬位的數字
a[2] = (num/100000)%10; //取十萬位的數字
a[3] = (num/10000)%10; //取萬位的數字
a[4] = (num/1000)%10; //取千位的數字
a[5] = (num/100)%10; //取百位的數字
a[6] = (num/10)%10; //取十位的數字
a[7] = num%10; //取個位的數字
for(int j=0;j<8;j++)
{
a[j]+=6; //每位數字加上6
a[j]%=10; //除以10代替該數字
}
//交換
for(int j=0;j<=3;j++)
{
one = a[j];
a[j] = a[7-j];
a[7-j] =one;
}
System.out.print("加密後的數字為:");
for(int j=0;j<8;j++)
System.out.print(a[j]);
}
} //版權所有
*