WSTI

11d_1

Jan 5th, 2012
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <ctype.h>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. /*
  9. napisać funkcję konwertującą w łańcuchu znaków małe litery na wielki i odwrotnie,
  10. łańcuch znaków zdefiniować w postaci tablicy znaków, wykorzystać funkcje standardowe z biblioteki ctype; sprawdzić działanie funkcji;
  11. */
  12.  
  13. void konwertuj(string &chain)
  14. {
  15.        int i=0;
  16.   while (chain[i])
  17.   {
  18.     if (islower(chain[i]))
  19.     {
  20.        chain[i]=toupper(chain[i]);
  21.     }
  22.     else
  23.     {
  24.         chain[i]=tolower(chain[i]);
  25.     }
  26.     i++;
  27.   }
  28. }
  29.  
  30. int main ()
  31. {
  32.  
  33.   string tekst="ten tekst ZMIENIMY";
  34.   konwertuj(tekst);
  35.   cout << tekst << endl;
  36.  
  37.   getch();
  38.  
  39.   return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment