Created
January 12, 2014 08:00
-
-
Save liuchang0812/8382086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package exam; | |
import java.util.Scanner; | |
import java.util.concurrent.*; | |
import java.lang.Thread; | |
class CryptionThread extends Thread { | |
public long srcnum; | |
CryptionThread(long scrnum) | |
{ | |
srcnum = scrnum; | |
} | |
public void run() | |
{ | |
long nums[] = new long[4]; | |
int cnt = 0; | |
while( srcnum != 0) | |
{ | |
nums[cnt] = srcnum % 10; | |
srcnum /= 10 ; | |
} | |
for (int i = 0;i < 4;i ++) | |
{ | |
nums[i] = (nums[i] + 5) % 10; | |
} | |
long tmp; | |
tmp = nums[1]; | |
nums[1] = nums[3]; | |
nums[3] = tmp; | |
tmp = nums[0]; | |
nums[0] = nums[2]; | |
nums[2] = tmp; | |
long ans = 0; | |
for (int i = 0;i < 4;i ++) | |
ans = ans * 10 + nums[i]; | |
System.out.println(ans); | |
} | |
} | |
public class cryption { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
System.out.println("input a num"); | |
Scanner cin = new Scanner(System.in); | |
long src; | |
while (cin.hasNext()) | |
{ | |
src = cin.nextLong(); | |
Thread thread = new CryptionThread(src); | |
try { | |
thread.join(); | |
thread.run(); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment