mcgluszak

bonus

Oct 15th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.80 KB | None | 0 0
  1. je = {0=>'0',1=>'1',2=>'2',3=>'3',4=>'4',5=>'5',6=>'6',7=>'7',8=>'8',9=>'9',10=>'A'}
  2. sz = {0=>'0',1=>'1',2=>'2',3=>'3',4=>'4',5=>'5',6=>'6',7=>'7',8=>'8',9=>'9',10=>'A',11=>'B',12=>'C',13=>'D',14=>'E',15=>'F'}
  3. #wpisujesz se w pierwszej linijce liczbę ile liczb chcesz zamienic
  4. # a potem w każdej linijce liczbę którą chcesz zamienić
  5. #czyli na przykład
  6. #2
  7. #10
  8. #200
  9.  
  10. gets.chomp.to_i.times do
  11.     meh = gets.chomp.to_i
  12.     liczba = meh
  13.     cyfry = []
  14.     until liczba == 0
  15.  
  16.     reszta = liczba % 16
  17.     cyfry << reszta
  18.     liczba = (liczba-reszta) / 16
  19.     end
  20.    
  21.     for e in cyfry.reverse
  22.         print sz[e]
  23.     end
  24.     print " "
  25.     liczba = meh
  26.     cyfry = []
  27.     until liczba == 0
  28.         reszta = liczba % 11
  29.         cyfry << reszta
  30.         liczba = (liczba-reszta) / 11
  31.     end
  32.    
  33.     for e in cyfry.reverse
  34.         print je[e]
  35.     end
  36.     print "\n"
  37. end
Advertisement
Add Comment
Please, Sign In to add comment