/* number of 4 */
#include <stdio.h>
#define FAC 10
int crypt( int n);
int decrypt( int n);
int mc( int n, int );
int getSalt();
int getDeSalt();
int main(){
int num;
scanf("%d",&num);
printf("crypt:%d\n",crypt(num));
printf("decrypt:%d\n",decrypt(crypt(num)));
}
int crypt( int n ){
return mc( n , 0 );
}
int decrypt( int n ){
return mc( n , 1 );
}
int mc(int n,int type){
int a, b, c, d, numCopy = n,salt = 0;
a = numCopy / 1000;
b = (numCopy % 1000) / 100;
c = (numCopy % 100) /10;
d = numCopy % 10;
switch( type ){
case 0:
salt = getSalt();
break;
case 1:
salt = getDeSalt();
break;
default:
salt = getSalt();
}
a = ( a + salt ) % 10;
b = ( b + salt ) % 10;
c = ( c + salt ) % 10;
d = ( d + salt ) % 10;
return c * 1000 + d * 100 + a * 10 + b;
}
int getSalt(){
return 7;
}
int getDeSalt(){
return FAC - (getSalt() % 10);
}
/* number of 4 */#include #define FAC 10int crypt( int n);int decrypt( int n);int mc( int n, int );int getSalt();int getDeSalt();int main(){ int num; scanf("%d",&num); printf("crypt:%d\n"