Advertisement
sellmmaahh

OR-2013-Datoteka.Isteifre

Aug 12th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.91 KB | None | 0 0
  1.  
  2. #include<stdio.h>
  3. #include<math.h>
  4.  
  5. int JednakeCifre (int *niz, int vel) {
  6.     int i, br_istih=0;
  7.     for (i=0; i<vel; i++) {
  8.             if (niz[i]%10==niz[i]) br_istih++;
  9.          else { int temp=niz[i];
  10.          int cifra=temp%10;
  11.                 temp/=10;
  12.                 while (cifra==temp%10) {
  13.                         temp/=10;
  14.                 if (temp==0) br_istih++;
  15.  
  16.  
  17.          }
  18.     }}
  19.     return br_istih;
  20. }
  21.  
  22.  
  23. int main () {
  24.     FILE *ulaz, *izlaz;
  25.     ulaz=fopen("mjerenja.txt", "r");
  26.     if (ulaz==NULL) {
  27.         printf("Greska.");
  28.         exit(1);
  29.     }
  30.    izlaz=fopen("statistika.txt","w");
  31.    if (izlaz==NULL) {
  32.     printf("Greska");
  33.     fclose(ulaz);
  34.     exit(1);
  35.    }
  36.    int i=0;
  37.    int  niz[500];
  38.    while(fscanf(ulaz,"%d",&niz[i])!=EOF && i<500) i++;
  39.   int broj_istih=JednakeCifre(niz,i);
  40.   fprintf(izlaz,"%d",broj_istih);
  41.   fclose(ulaz);
  42.   fclose(izlaz);
  43.   return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement