hopingsteam

Untitled

Mar 14th, 2020
118
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. #include <string>
  4.  
  5. #include <fstream>
  6.  
  7. #include <vector>
  8.  
  9. #include <string>
  10.  
  11. #include <string.h>
  12.  
  13. using namespace std;
  14.  
  15. ifstream fin("date.in");
  16.  
  17. vector<string> vectorCuv;
  18.  
  19. string sir, vowels = "aeiouAEIOU";
  20.  
  21. int i, j, r, nrVoci, nrVocj;
  22.  
  23. int main() {
  24. while(fin >> sir) {
  25. vectorCuv.push_back(sir);
  26. }
  27. for(i = 0; i < vectorCuv.size() - 1; ++i) {
  28. for(j = i + 1; j < vectorCuv.size(); ++j) {
  29. nrVoci = nrVocj = 0;
  30. for(r = 0; r < vectorCuv[i].size(); ++r) {
  31. if(vowels.find(vectorCuv[i][r]) != -1) {
  32. ++nrVoci;
  33. }
  34. }
  35. for(r = 0; r < vectorCuv[j].size(); ++r) {
  36. if(vowels.find(vectorCuv[j][r]) != -1) {
  37. ++nrVocj;
  38. }
  39. }
  40. //cout << vectorCuv[i] << "(" << nrVoci << ")\n";
  41. //cout << vectorCuv[j] << "(" << nrVocj << ")\n\n";
  42. if(nrVoci > nrVocj) {
  43. swap(vectorCuv[i], vectorCuv[j]);
  44. } else if(nrVoci == nrVocj) {
  45. if(vectorCuv[i] > vectorCuv[j]) {
  46. swap(vectorCuv[i], vectorCuv[j]);
  47. }
  48. }
  49. }
  50. }
  51. vectorCuv[vectorCuv.size()] = '\0';
  52. for(i = 0; i < vectorCuv.size(); ++i) {
  53. cout << vectorCuv[i] << '\n';
  54. }
  55. return 0;
  56. }
RAW Paste Data