Guest User

Untitled

a guest
Jan 13th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int ileliter(char* t);
  9. int ilewyrazow(char* t);
  10. char* usunspacje(char t[]);
  11.  
  12.  
  13.  
  14. int main()
  15. {
  16. char t[200];
  17. gets(t);
  18. ileliter(t);
  19. cout<<"Tekst bez zbednych spacji:"<<endl;
  20. usunspacje(t);
  21. for(int i=0;t[i]!=0;i++)
  22. cout<<t[i];
  23. ilewyrazow(t);
  24.  
  25.  
  26. }
  27.  
  28.  
  29.  
  30.  
  31. int ileliter(char* t)
  32. {
  33. return printf("liczba znakow = %d\n",strlen(t));
  34.  
  35. }
  36.  
  37.  
  38. int ilewyrazow(char* t)
  39. {
  40. int licznik=1;
  41. for(int i=0;t[i]!=0;i++)
  42. {
  43. if (t[i]==' '&& t[i+1]!=' ')
  44. licznik++;
  45. }
  46.  
  47. }
  48.  
  49.  
  50.  
  51. char* usunspacje(char t[])
  52. {
  53. if( t[0]=='\0' )
  54. return t;
  55. int i=1;
  56. while( t[i]!='\0' )
  57. if( t[i]==' ' && t[i+1]==' ' )
  58. strcpy( &t[i+1], &t[i+2] );
  59. else
  60. i++;
  61. return t;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment