Toxotsist

T5

Sep 14th, 2021 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. public class Reverse {
  2.     public static int Reverse(int n, int i) {
  3.        if (n == 0){
  4.             return i;
  5.        } else {
  6.            return Reverse( n/10, i*10 + n%10 );
  7.        }
  8.     }
  9.     public static void main(String[] args) {
  10.         System.out.println(Reverse(23234423, 0));
  11.     }
  12. }
  13. //////////////////////////////////////////////////
  14. import java.util.Scanner;
  15.  
  16. public class Reverse {
  17.     public static void Reverse() {
  18.         Scanner scan = new Scanner(System.in);
  19.         int n = scan.nextInt();
  20.         if (n > 0) {
  21.             if (n % 2 == 1) {
  22.                 System.out.println(n);
  23.                 Reverse();
  24.             } else {
  25.                 Reverse();
  26.             }
  27.         }
  28.     }
  29.     public static void main(String[] args) {
  30.         Reverse();
  31.     }
  32. }
  33.  
  34. /////////////////////////////////////////////////
  35. import java.util.Scanner;
  36.  
  37. public class Reverse {
  38.     public static int Reverse() {
  39.         Scanner scan = new Scanner(System.in);
  40.         int n = scan.nextInt();
  41.         if (n == 1) {
  42.             int n2 = scan.nextInt();
  43.             if (n2 == 1) {
  44.                 return Reverse() + n + n2;
  45.             }
  46.             else {
  47.                 int n3 = scan.nextInt();
  48.                 if (n3 == 1) {
  49.                     return Reverse() + n + n2 + n3;
  50.                 } else {
  51.                     return n + n2 + n3;
  52.                 }
  53.             }
  54.         }
  55.         else {
  56.             int n2 = scan.nextInt();
  57.             if (n2 == 1) {
  58.                 return Reverse() + n + n2;
  59.             } else {
  60.                 return n + n2;
  61.             }
  62.         }
  63.     }
  64.     public static void main(String[] args) {
  65.         System.out.println(Reverse());
  66.     }
  67. }
  68. //////////////////////////////////////////////////////
Add Comment
Please, Sign In to add comment