Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define N 26
- int indexof(char c) {
- return c - 'a';
- }
- // ritorna 1 se non ci sono doppie 0 altrimenti.
- char nodoppie(char stringa[]) {
- int occorrenze[N] = { 0 };
- int i;
- for (char *c = stringa; *c != '\0'; ++c) {
- i = indexof(*c);
- if (occorrenze[i] == 1) return 0;
- else occorrenze[i]++;
- }
- return 1;
- }
- int main() {
- char test1[] = "cisonodoppie";
- char test2[] = "quino";
- printf("%d %d\n", nodoppie(test1), nodoppie(test2));
- }
Advertisement
Add Comment
Please, Sign In to add comment