nsnikolova1

12

May 18th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.14 KB | None | 0 0
  1. // Podgotovka izpit SORT po vid.cpp : This file contains the 'main' function. Program execution begins and ends there.
  2. //
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <string>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     string input;
  14.     int NumChar;
  15.     vector<int> vectD;
  16.     vector<char> vectSmall;
  17.     vector<char> vectOther;
  18.    
  19.     cin >> NumChar;
  20.     cin.ignore();
  21.     getline(cin, input);
  22.     for (int i = 0; i < input.size(); i++)
  23.     {
  24.         if (isdigit(input[i])) //ako e chislo
  25.         {
  26.             vectD.push_back((input[i]-'0'));
  27.         }
  28.         else if (input[i] < 'z' && input[i]>'a') //ako e malka bukva
  29.         {
  30.         vectSmall.push_back(input[i]);
  31.         }
  32.         else if(input[i]==' ')
  33.         {
  34.             continue;
  35.         }
  36.         else
  37.         {
  38.             vectOther.push_back(input[i]);
  39.         }
  40.      
  41.     }
  42.  
  43.     //pechat
  44.    
  45.        sort(vectD.begin(), vectD.end());
  46.        for (auto it = vectD.begin(); it != vectD.end(); it++)
  47.        {
  48.            cout << *it << " ";
  49.                  
  50.         }
  51.        cout << endl;
  52.    
  53.  
  54.    
  55.         sort(vectSmall.begin(), vectSmall.end());
  56.         for (auto it = vectSmall.begin(); it != vectSmall.end(); it++)
  57.         {
  58.         cout << *it << " " ;
  59.         }
  60.         cout << endl;
  61.    
  62.    
  63.         sort(vectOther.begin(), vectOther.end());
  64.         for (auto it = vectOther.begin(); it != vectOther.end(); it++)
  65.         {
  66.         cout << *it << " " ;
  67.         }
  68.            
  69.  
  70. }
  71.  
  72. // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
  73. // Debug program: F5 or Debug > Start Debugging menu
  74.  
  75. // Tips for Getting Started:
  76. //   1. Use the Solution Explorer window to add/manage files
  77. //   2. Use the Team Explorer window to connect to source control
  78. //   3. Use the Output window to see build output and other messages
  79. //   4. Use the Error List window to view errors
  80. //   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
  81. //   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment