Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int length (char *s) {
- int d=0;
- while (*(s++)!='\0') d++;
- return d;
- }
- int JeLiMalo (char c) {
- if (c>='a' && c<='z') return 1;
- return 0;
- }
- int JeLiVeliko (char c) {
- if (c>='A' && c<='Z') return 1;
- return 0;
- }
- int BrojDuplihSlova(char *s) {
- int slova[27], brojac=0, duzina=length(s), i;
- for(i=0; i<27; i++) slova[i]=0;
- for (i=0; i<duzina; i++) {
- if (JeLiMalo(s[i])) slova[s[i]-'a']++;
- else if (JeLiVeliko(s[i])) slova[s[i]-'A']++;
- }
- for (i=0; i<27; i++) {
- if (slova[i]==2) brojac++;
- }
- return brojac;
- }
- int main () {
- char s[]="Selma je bila ovdje.";
- printf("Broj duplih slova: %d", BrojDuplihSlova(s));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement