Advertisement
sellmmaahh

OR-Umjesto I ubaci ABA

Sep 6th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 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. void insert (char *s, char *rijec, int indeks) {
  22.     int i;
  23.     for (i=length(s)+length(rijec); i>=indeks+length(rijec); i--)
  24.         s[i]=s[i-length(rijec)];
  25.  
  26.     for (i=0; i<length(rijec); i++)
  27.           s[i+indeks]=rijec[i];
  28. }
  29.  
  30. void Ubaci (char *s) {
  31.     char rijec[4]="aba";
  32.     int i, duzina=length(s);
  33.     for (i=0; i<duzina; i++) {
  34.             if (s[i]=='i' || s[i]=='I') {
  35.                     cut (s, i, 1);
  36.                     insert(s,rijec,i);
  37.                    i+=(length(rijec));
  38.             }
  39.     }
  40. }
  41.  
  42. int main () {
  43.     char s[]="Selma ide kuci i zuri .";
  44.     Ubaci(s);
  45.     printf("%s",s);
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement