Advertisement
sellmmaahh

OR-skripta Adijata-zad 46-Br slova koja se ponavljaju 2 puta

Aug 26th, 2015
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int VelikoSlovo (char c) {
  6. if (c>='A' && c<='Z') return 1;
  7. return 0;
  8. }
  9.  
  10. int MaloSlovo (char c) {
  11. if (c>='a' && c<='z') return 1;
  12. return 0;
  13. }
  14. int length (char *s) {
  15.     int duzina=0;
  16.     while (*(s++)!='\0') duzina++;
  17.     return duzina;
  18. }
  19.  
  20. int Funkcija (char *s) {
  21.     int br=0,i, duz=length(s);
  22.     int slova[25];
  23.      for (i=0; i<25; i++) slova[i]=0;
  24.     for (i=0; i<duz; i++) {
  25.             if (VelikoSlovo(s[i])) slova[s[i]-'A']++;
  26.             else if (MaloSlovo(s[i])) slova[s[i]-'a']++;
  27.     }
  28.     for (i=0; i<25; i++) {
  29.             if (slova[i]==2) br++;
  30.     }
  31.     return br;
  32. }
  33.  
  34.  
  35. int main () {
  36.     printf("Broj slova koja se ponavljaju 2 puta u recenici: %d", Funkcija("Abeceda"));
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement