Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Reverse {
- public static int Reverse(int n, int i) {
- if (n == 0){
- return i;
- } else {
- return Reverse( n/10, i*10 + n%10 );
- }
- }
- public static void main(String[] args) {
- System.out.println(Reverse(23234423, 0));
- }
- }
- //////////////////////////////////////////////////
- import java.util.Scanner;
- public class Reverse {
- public static void Reverse() {
- Scanner scan = new Scanner(System.in);
- int n = scan.nextInt();
- if (n > 0) {
- if (n % 2 == 1) {
- System.out.println(n);
- Reverse();
- } else {
- Reverse();
- }
- }
- }
- public static void main(String[] args) {
- Reverse();
- }
- }
- /////////////////////////////////////////////////
- import java.util.Scanner;
- public class Reverse {
- public static int Reverse() {
- Scanner scan = new Scanner(System.in);
- int n = scan.nextInt();
- if (n == 1) {
- int n2 = scan.nextInt();
- if (n2 == 1) {
- return Reverse() + n + n2;
- }
- else {
- int n3 = scan.nextInt();
- if (n3 == 1) {
- return Reverse() + n + n2 + n3;
- } else {
- return n + n2 + n3;
- }
- }
- }
- else {
- int n2 = scan.nextInt();
- if (n2 == 1) {
- return Reverse() + n + n2;
- } else {
- return n + n2;
- }
- }
- }
- public static void main(String[] args) {
- System.out.println(Reverse());
- }
- }
- //////////////////////////////////////////////////////
Add Comment
Please, Sign In to add comment