Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int JednakeCifre (int *niz, int vel) {
- int i, br_istih=0;
- for (i=0; i<vel; i++) {
- if (niz[i]%10==niz[i]) br_istih++;
- else { int temp=niz[i];
- int cifra=temp%10;
- temp/=10;
- while (cifra==temp%10) {
- temp/=10;
- if (temp==0) br_istih++;
- }
- }}
- return br_istih;
- }
- int main () {
- FILE *ulaz, *izlaz;
- ulaz=fopen("mjerenja.txt", "r");
- if (ulaz==NULL) {
- printf("Greska.");
- exit(1);
- }
- izlaz=fopen("statistika.txt","w");
- if (izlaz==NULL) {
- printf("Greska");
- fclose(ulaz);
- exit(1);
- }
- int i=0;
- int niz[500];
- while(fscanf(ulaz,"%d",&niz[i])!=EOF && i<500) i++;
- int broj_istih=JednakeCifre(niz,i);
- fprintf(izlaz,"%d",broj_istih);
- fclose(ulaz);
- fclose(izlaz);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement