Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int znaki(char txt[], int i)
- {
- if(txt[i]=='\0')
- return i;
- else
- return znaki(txt, i+1);
- }
- int znakiBezSpacji(char txt[], int i, int j)
- {
- if(txt[i]=='\0')
- {
- return i-j;
- }
- else
- {
- if(txt[i]==32)
- return znakiBezSpacji(txt, i+1, j+1);
- else
- return znakiBezSpacji(txt, i+1, j);
- }
- }
- void wypiszTekst(char txt[], int i)
- {
- if(txt[i]=='\0')
- return;
- cout<<txt[i];
- wypiszTekst(txt, i+1);
- }
- void tekstWspak(char txt[], int i)
- {
- if(txt[i]=='\0')
- return;
- tekstWspak(txt, i+1);
- cout<<txt[i];
- }
- int main()
- {
- char txt[100];
- cout<<"Podaj tekst: "<<endl;
- cin.getline(txt, 100);
- cout<<"Liczba znakow: "<<endl;
- cout<<znaki(txt, 0);
- cout<<'\n'<<"Liczba znakow bez spacji: "<<endl;
- cout<<znakiBezSpacji(txt, 0, 0);
- cout<<'\n'<<"Tekst: "<<endl;
- wypiszTekst(txt, 0);
- cout<<'\n'<<"Tekst wspak: "<<endl;
- tekstWspak(txt, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement