MeehoweCK

Untitled

May 15th, 2020
1,327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <cctype>
  2. #include <string>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. string initials(string tekst)
  8. {
  9.     string wynik = " ";
  10.     wynik[0] = tekst[0];
  11.  
  12.     for(unsigned i = 0; i < tekst.size(); ++i)
  13.     {
  14.         if(tekst[i] == ' ')
  15.             wynik += tekst[i + 1];
  16.     }
  17.     return wynik;
  18. }
  19.  
  20. int main()
  21. {
  22.     cout << initials("Piotr Kowalski") << endl;
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment