Advertisement
rsvaco

entregable1A prg 2016

Feb 17th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1.     public static int sumaCifrasDif(int n, int x) {
  2.         if (n < 10) {
  3.             if (n == x) { return 0; }
  4.             else return n;
  5.         }
  6.         else {
  7.             if (n % 10 != x) { return n % 10 + sumaCifrasDif(n / 10, x); }
  8.             else return sumaCifrasDif(n / 10, x);
  9.         }
  10.     }
  11.    
  12.     public static int filtraCifrasX(int n, int x) {
  13.         if (n < 10) {
  14.             if (n == x) { return 0; }
  15.             else return n;
  16.         }
  17.         else {
  18.             if (n % 10 != x) { return (n % 10) + filtraCifrasX(n / 10, x)*10; }
  19.             else return filtraCifrasX(n / 10, x)*10;
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement