Advertisement
sellmmaahh

OR-Izbaci Rijec Sa Cifrom Na Prvom Mjestu

Sep 6th, 2015
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 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) {
  31.     int i, duzina=length(s),poc,kraj;
  32.     for (i=0; i<duzina; i++) {
  33.             if (JeLiBroj(s[i]) && JeLiSlovo(s[i+1])) {
  34.                 poc=i;
  35.                   i++;
  36.                   while (JeLiSlovo(s[i])) i++;
  37.                   kraj=i;
  38.               cut (s, poc, kraj-poc);
  39.               i-=(kraj-poc);
  40.             }
  41.     }
  42. }
  43.  
  44. int main () {
  45.     char s[]="Selma 2je  bila  3ovdje.";
  46.     Izbaci(s);
  47.     printf("%s", s);
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement