Advertisement
Mixilino

podstring

Apr 20th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. int daLiJeSamoglasnik(char str) {
  2.  
  3.     char samoglasnici[11] = "aeiouAEIOU";
  4.     for (int i = 0; i < 10; i++)
  5.     {
  6.         if (str == samoglasnici[i]) {
  7.             return 1;
  8.         }
  9.     }
  10.     return 0;
  11. }
  12.  
  13. void najkraciPodstringSamoglasnika2(char str1[], char str2[]) {
  14.     int i = 0, j = 0, max = 0, duzina, index, temp = 0;
  15.     while (str1[i] != '\0') {
  16.         j = i;
  17.         duzina = 0;
  18.         if (daLiJeSamoglasnik(str1[i])) {
  19.             while (daLiJeSamoglasnik(str1[j]) && str1[j]!='\0') {
  20.                 duzina++;
  21.                 j++;
  22.             }
  23.         }
  24.         if (duzina < max && duzina != 0 && temp == 1) {
  25.             index = i;
  26.             max = duzina;
  27.         }
  28.         else if (temp == 0 && duzina > 0) {
  29.             index = i;
  30.             max = duzina;
  31.             temp++;
  32.         }
  33.         i = i + duzina + 1;
  34.     }
  35.     for (int i = index; i < duzina + index; i++)
  36.     {
  37.         str2[i - index] = str1[i];
  38.     }
  39.     str2[duzina] = '\0';
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement