TeamFocus-Matija

Treci zadatak ISPIT

Aug 21st, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. typedef char STRING[50];
  7.  
  8. int daLiSeNalaziUStringu(STRING B, int *brEl,char slovo){
  9.     int i;
  10.    
  11.     for ( i = 0; i < *brEl; i++)
  12.     {
  13.         if (B[i] == slovo){
  14.             B[i] = B[*brEl-1];
  15.             (*brEl)--;
  16.             return 1;
  17.         }
  18.     }
  19.     return 0;
  20. }
  21.  
  22. int daLiSuAnagrami(STRING A,STRING B){
  23.     int i;
  24.     int brEl = strlen(B);
  25.    
  26.  
  27.     for ( i = 0; i < strlen(A); i++)
  28.     {
  29.         if (daLiSeNalaziUStringu(B,&brEl,A[i])==0){
  30.             return 0;
  31.         }
  32.     }
  33.     return 1;
  34. }
  35.  
  36.  
  37. int main(void){
  38.     STRING A = "1ab4gtt";
  39.     STRING B = "tabtg14";
  40.  
  41.     if (daLiSuAnagrami(A, B) == 1){
  42.         printf("Ova dva niza su anagrami!\n\n");
  43.     }
  44.     else{
  45.         printf("Ova dva niza nisu anagrami!\n\n");
  46.     }
  47.  
  48.  
  49.     return 0;
  50. }
Add Comment
Please, Sign In to add comment