Advertisement
sellmmaahh

OR-Izbaci Rijec N Duzine

Sep 6th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int length (char *s) {
  6.     int d=0;
  7.     while (*(s++)!='\0') d++;
  8.     return d;
  9. }
  10.  
  11. void cut(char *string, int indeks, int len)
  12. {
  13.     int i;
  14.  
  15.     for(i = indeks; i <= length(string) - len; i++)
  16.     {
  17.         string[i] = string[i + len];
  18.     }
  19.  
  20. }
  21.  
  22. int JeLiBroj (char c) {
  23.     if (c>='0' && c<='9') return 1;
  24.     return 0;
  25. }
  26. int JeLiSlovo (char c) {
  27.     if (tolower(c)>='a' && tolower(c)<='z') return 1;
  28.     return 0;
  29. }
  30. void Izbaci (char *s, int n) {
  31.     int i, duzina=length(s),poc,kraj;
  32.     char *p=s;
  33.     for (i=0; i<duzina; i++) {
  34.             if (JeLiSlovo(s[i]) && (s[i-1]==' ' || s==p)) {
  35.                 poc=i;
  36.                   i++;
  37.                   while (JeLiSlovo(s[i])) i++;
  38.                   kraj=i;
  39.                   if ((kraj-poc)==n) {
  40.               cut (s, poc, kraj-poc);
  41.               i-=(kraj-poc);
  42.                   }
  43.             }
  44.     }
  45. }
  46.  
  47. int main () {
  48.     char s[]="Selma je  bila  ovdje jucer.";
  49.     Izbaci(s,5);
  50.     printf("%s", s);
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement