Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<string>
  4. #include<sstream>
  5.  
  6.  
  7. using namespace std;
  8.  
  9.  
  10. int firstNonRepeating(vector<unsigned int> &arr, int & n)
  11. {
  12.  
  13.     for (int i = 0; i < n; i++) {
  14.         int j;
  15.         for (j = 0; j < n; j++)
  16.             if (i != j && arr[i] == arr[j])
  17.                 break;
  18.         if (j == n)
  19.             return arr[i];
  20.     }
  21.     return -1;
  22. }
  23. void Dec2Hex(int no)
  24. {
  25.     int hex=0;
  26.     if(!no)
  27.         return;
  28.     else {
  29.         hex=no%16;
  30.         Dec2Hex(no/16);
  31.     }
  32.     if(hex>9)
  33.         printf("%c",'a'+(hex-10));
  34.     else
  35.         printf("%d",hex);
  36.    
  37.    
  38. }
  39.    
  40.  
  41.  
  42. int main(){
  43.    
  44.     cin.sync_with_stdio(false);
  45.     cout.sync_with_stdio(false);
  46. string Input;
  47.  
  48. // while (Input != ".")
  49. //  {
  50. //      cin >> Input;
  51. //          if (Input == ".")
  52. //               break;
  53.      
  54. //  }
  55. getline(cin, Input, '.');
  56. vector<unsigned int> dna;
  57.  
  58. for (unsigned int i = 0; i < Input.length(); i += 5)
  59. {
  60.     stringstream stream(Input.substr(i, 5));
  61.     unsigned int num;
  62.     while (stream >> hex >> num)
  63.     {
  64.         dna.push_back(num);
  65.     }
  66.  
  67. }
  68.  
  69.  
  70. int size = dna.size();
  71.  
  72.   Dec2Hex(firstNonRepeating(dna, size));
  73.  
  74. return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement