Advertisement
Guest User

marcin

a guest
Nov 24th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. char input[3] = {0,0,0};
  5. char litera;
  6.  
  7. int main() {
  8. cin >> input;
  9. input[0] -= '0'; //robimy z tego wartość
  10.  
  11. input[1] = (input[1] <= '9') ? input[1] - '0' : input[1] - 'A' + 10;
  12.  
  13. /* równoważne "prościej" poniżej
  14. if (input[1] <= '9')
  15. {
  16. input[1] -= '0';
  17. }
  18. else
  19. {
  20. input[1] = input[1] - 'A' + 10;
  21. }*/
  22.  
  23. litera = input[0] * 16 + input[1];
  24.  
  25. cout << (int)litera << endl << litera;
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement