Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- using namespace std;
- int ileliter(char* t);
- int ilewyrazow(char* t);
- char* usunspacje(char t[]);
- int main()
- {
- char t[200];
- gets(t);
- ileliter(t);
- cout<<"Tekst bez zbednych spacji:"<<endl;
- usunspacje(t);
- for(int i=0;t[i]!=0;i++)
- cout<<t[i];
- ilewyrazow(t);
- }
- int ileliter(char* t)
- {
- return printf("liczba znakow = %d\n",strlen(t));
- }
- int ilewyrazow(char* t)
- {
- int licznik=1;
- for(int i=0;t[i]!=0;i++)
- {
- if (t[i]==' '&& t[i+1]!=' ')
- licznik++;
- }
- }
- char* usunspacje(char t[])
- {
- if( t[0]=='\0' )
- return t;
- int i=1;
- while( t[i]!='\0' )
- if( t[i]==' ' && t[i+1]==' ' )
- strcpy( &t[i+1], &t[i+2] );
- else
- i++;
- return t;
- }
Advertisement
Add Comment
Please, Sign In to add comment