SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <stdio.h> | |
| 2 | #include <stdlib.h> | |
| 3 | #include <math.h> | |
| 4 | ||
| 5 | int funkcija(int niz[], int velicina) | |
| 6 | {
| |
| 7 | int prethodna, sad, log, i, brojac = 0; | |
| 8 | ||
| 9 | for (i=0; i<velicina; i++) | |
| 10 | {
| |
| 11 | ||
| 12 | prethodna = niz[i]%10; | |
| 13 | while (niz[i] != 0) | |
| 14 | {
| |
| 15 | sad = niz[i] % 10; | |
| 16 | niz[i]/=10; | |
| 17 | if (prethodna == sad) log = 1; | |
| 18 | else {log = 0; break;}
| |
| 19 | prethodna = sad; | |
| 20 | ||
| 21 | } | |
| 22 | if (log == 1) brojac++; | |
| 23 | ||
| 24 | } | |
| 25 | - | if (niz[i] <= '9' && niz[i] >= '0') brojac++; |
| 25 | + | |
| 26 | return brojac; | |
| 27 | } | |
| 28 | ||
| 29 | int main() | |
| 30 | {
| |
| 31 | FILE *ulaz; | |
| 32 | int niz[100], vel = 0; | |
| 33 | char znak; | |
| 34 | ulaz = fopen ("mjerenja.txt", "r");
| |
| 35 | if (ulaz == NULL) | |
| 36 | {
| |
| 37 | printf("Nije uspjelo otvaranje datoteke..\n");
| |
| 38 | exit(1); | |
| 39 | } | |
| 40 | ||
| 41 | while(fscanf(ulaz, "%d%c", &niz[vel++], &znak) != EOF); | |
| 42 | printf("%d ", funkcija(niz, vel));
| |
| 43 | fclose(ulaz); | |
| 44 | return 0; | |
| 45 | } |