Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. //#include <string>
  3. #include <chrono>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     auto begin = chrono::high_resolution_clock::now();
  9.  
  10.     int n = 23;
  11.     //std::cin >> n;
  12.     std::string str = "";
  13.  
  14.     while (n != 0)    
  15.     {
  16.         if (n % 2 == 0)
  17.         {
  18.             str.insert(0, "S");
  19.         }
  20.         else { str.insert(0, "SX"); }
  21.         n /= 2;
  22.     }
  23.     //str = "SXabcdefgh";
  24.  
  25.     if (str.substr(0,2) == "SX")
  26.     {
  27.         cout << str.substr(2).c_str() << '\n';
  28.     }
  29.     else cout << str.c_str() << '\n';
  30.    
  31.     cout << str.c_str() << '\n';
  32.    
  33.    
  34.    
  35.     auto end = chrono::high_resolution_clock::now();
  36.     chrono::duration<float> time = end - begin;
  37.     cout << time.count() << '\n';
  38.    
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement