MeehoweCK

Untitled

Feb 10th, 2021
700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. // Oliwia Ilnicka 261681
  4.  
  5. using namespace std;
  6.  
  7. string wspak(string tekst)
  8. {
  9.     string wynik = "";
  10.  
  11.     for(int i = tekst.size() - 1; i >= 0; --i)
  12.         wynik += tekst[i];
  13.     return wynik;
  14. }
  15.  
  16. int suma_ascii(string tekst)
  17. {
  18.     unsigned dlugosc = tekst.size();
  19.     int suma = 0;
  20.  
  21.     for(unsigned i = 0; i < dlugosc; ++i)
  22.         suma += static_cast<int>(tekst[i]);
  23.     return suma;
  24. }
  25.  
  26. string duze_litery(string tekst)
  27. {
  28.     unsigned dlugosc = tekst.size();
  29.     string wynik = "";
  30.  
  31.     for(unsigned i = 0; i < dlugosc; ++i)
  32.     {
  33.         if(tekst[i] >= 'a' && tekst[i] <= 'z')
  34.             wynik += toupper(tekst[i]);
  35.         else
  36.             wynik += tolower(tekst[i]);
  37.     }
  38.  
  39.     return wynik;
  40. }
  41.  
  42. int main()
  43. {
  44.     string dane = "Oliwia Ilnicka";
  45.     cout << dane << endl << wspak(dane) << endl;
  46.     cout << suma_ascii(dane) << endl;
  47.     cout << duze_litery(dane) << endl;
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment