logancberrypie

Thoughts

Nov 20th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. string convert_lower(string word);
  7. string sort(string friends[]);
  8.  
  9. int main()
  10. {
  11.     string friends[] = {"C++","CS:GO","Cancer retards","White people","Trump","Cyka","Ruski","men?","Shrimplord"};
  12.     int n = sizeof(friends)/sizeof(friends[0]);
  13.     for ( int i = 0; i < n; i++) {
  14.     friends[i] = convert_lower(friends[i]);
  15.     }
  16.     for ( int i = 0; i < n; i++) {
  17.         for ( int j = 0; j < n; j++) {
  18.             if (friends[i].at(0) < friends[j].at(0)) {
  19.                 string tmp = friends[i];
  20.                 friends[i] = friends[j];
  21.                 friends[j] = tmp;
  22.             }
  23.         }
  24.  
  25.     }
  26.  
  27.     for ( int i = 0; i < 9; i++) {
  28.         cout << friends[i] << endl;
  29.     }
  30.     return 0;
  31.  
  32.     ofstream output;
  33.     output.open("C:\Users\logan\meh.txt", fstream::out);
  34.     for (int i =0;i<n;i++)
  35.     {
  36.         output << friends[i] << endl;
  37.     }
  38.     output.close();
  39.  
  40.  
  41. }
  42.  
  43.  
  44. string sort(string* friends)
  45. {
  46.  
  47.     //Pointers are lyfe
  48.     return *friends;
  49. }
  50.  
  51. string convert_lower(string word)
  52. {
  53.     string final;
  54.    for (int i=0;i < word.size();i++)
  55.    {
  56.        final += tolower(word[i]);
  57.    }
  58.    return final;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment