Advertisement
MonsterScripter

CodinGame_2023_08_25__19_19_03__str_to_hex.cpp

Aug 25th, 2023
1,232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <sstream>
  6.  
  7. using namespace std;
  8.  
  9. /**
  10.  * Test 1
  11.  * Entrée :
  12.  * F
  13.  * Sortie attendue :
  14.  * 15
  15.  *
  16.  * Test 2
  17.  * Entrée :
  18.  * 5
  19.  * Sortie attendue :
  20.  * 5
  21.  *
  22.  * Test 3
  23.  * Entrée :
  24.  * FF
  25.  * Sortie attendue :
  26.  * 255
  27.  *
  28.  * Test 4
  29.  * Entrée :
  30.  * 4B68
  31.  * Sortie attendue :
  32.  * 19304
  33.  *
  34.  * Test 5
  35.  * Entrée :
  36.  * 83DF47
  37.  * Sortie attendue :
  38.  * 8642375
  39.  *
  40.  * Test 6
  41.  * Entrée :
  42.  * 10
  43.  * Sortie attendue :
  44.  * 16
  45.  */
  46.  
  47. int main()
  48. {
  49.     string number;
  50.     cin >> number; cin.ignore();
  51.  
  52.     unsigned int x;  
  53.     std::stringstream ss;
  54.     ss << std::hex << number;
  55.     ss >> x;
  56.     cout << x << endl;
  57.  
  58.     return 0;
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement