Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. int dlugosc(char txt[], int i, int j)
  7. {
  8.     if(txt[i]==32)
  9.         j++;
  10.     if(txt[i]=='\0')
  11.     {
  12.         i=i-j;
  13.         return i;
  14.     }
  15.     else
  16.         return dlugosc(txt, i+1, j);
  17. }
  18.  
  19. void wypiszTekst(char txt[], int i)
  20. {
  21.     if(txt[i]=='\0')
  22.         return;
  23.     cout<<txt[i];
  24.     wypiszTekst(txt, i+1);
  25. }
  26.  
  27. void tekstWspak(char txt[], int i)
  28. {
  29.     if(txt[i]=='\0')
  30.         return;
  31.     tekstWspak(txt, i+1);
  32.     cout<<txt[i];
  33. }
  34. int main()
  35. {
  36.     char txt[100];
  37.     cin.getline(txt, 100);
  38.     cout<<"Dlugosc tekstu: "<<endl;
  39.     cout<<dlugosc(txt, 0, 0);
  40.     cout<<'\n'<<"Tekst: "<<endl;
  41.     wypiszTekst(txt, 0);
  42.     cout<<'\n'<<"Tekst wspak:  "<<endl;
  43.     tekstWspak(txt, 0);
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement