1. Reverse (output-563412)
public class Encryp1 {
static int rev = 0;
public static void main(String[] args) {
reverse(123456);
System.out.println(rev);
}
static void reverse(int n) {
if (n == 0)
return;
rev = rev * 100 + (n % 100);
reverse(n / 100);
}
}
output
2.Reverse (ouput-456123)
public class Encryp2 {
static int rev = 0;
public static void main(String[] args) {
reverse(123456);
System.out.println(rev);
}
static void reverse(int n) {
if (n == 0)
return;
rev = rev * 1000 + (n % 1000);
reverse(n / 1000);
}
}
output
3.Reverse (output-135246)
public class Main {
public static void main(String[] args) {
int no = 123456;
int no1 = 100000;
String result1 = "";
String result2 = "";
while (no > 0 && no1 >= 1) {
int res = no / no1;
int res1 = res % 10;
result1 += res1;
no = no % no1;
no1 = no1 / 10;
if (no > 0 && no1 >= 1) {
res = no / no1;
int res2 = res % 10;
result2 += res2;
no = no % no1;
no1 = no1 / 10;
}
}
String result = result1 + result2;
System.out.println(result);
}
}
output



Top comments (0)