Advertisement
mali_cox

IzbaciSkafiskafnjak

Feb 8th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void IzbaciMax(char* s)
  4. {
  5.     char* p=s;
  6.     char* pt,*kt,*pm,*km,*pi,*ci;
  7.     int max=0;
  8.     while(*p != '\0')
  9.     {
  10.         if(*p>='a' && *p<='z' || *p>='A' && *p<='Z' && *(p-1)==' '  || p==s)
  11.         {
  12.             pt=p;
  13.             while(*p>='a' && *p<='z' || *p>='A' && *p<='Z')
  14.                 p++;
  15.             if(*p==' ' || *p=='\0')
  16.             {
  17.                 kt=p;
  18.                
  19.                 if(kt-pt>max)
  20.                 {
  21.                     max=kt-pt;
  22.                     pm=pt;
  23.                     km=kt;
  24.                 }
  25.             }
  26.         }
  27.         p++;
  28.     }
  29.     ci=km+1;
  30.     pi=pm;
  31.     while(*pi != '\0')
  32.     {
  33.         *pi=*ci;
  34.         pi++;
  35.         ci++;
  36.  
  37.     }
  38.    
  39.    
  40. }
  41.  
  42.  
  43. int main()
  44. {
  45.     printf("Dati string glasi: \n");
  46.     char string[]="Ovo je vas string i treba izbaciti skafiskafnjak";
  47.     printf("%s\n",string);
  48.     IzbaciMax(string);
  49.     printf("%s",string);
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement