Advertisement
sellmmaahh

OR-datoteka-ratsuce cifre.2013

Aug 26th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int JeLiURastucem (int n) {
  5.     int br=n;
  6.  
  7.       int cifra=br%10;
  8.             br/=10;
  9.      while (br!=0) {
  10.  
  11.         if (cifra<br%10) {
  12.             return 0;
  13.         }
  14.         else {
  15.                 cifra=br%10;
  16.         br/=10;
  17.         }
  18.      }
  19.      return 1;
  20. }
  21.  
  22. int BrRastucih (int *niz, int vel) {
  23.     int brojac=0; int i;
  24.     for (i=0; i<vel; i++) {
  25.             if (JeLiURastucem(niz[i])) brojac++;
  26.     }
  27.     return brojac;
  28. }
  29.  
  30. int main () {
  31. FILE *ulaz, *izlaz;
  32. ulaz=fopen("mjerenja.txt","r");
  33. if (ulaz==NULL) {
  34.         printf("Haos.");
  35. exit(1);
  36. }
  37. izlaz=fopen("statistika.txt", "w");
  38. if (izlaz==NULL) {
  39.     printf("Haos2");
  40.     fclose(ulaz);
  41.     exit(1);
  42. }
  43. int i=0;
  44. char c;
  45. int niz[100];
  46. do {
  47.         fprintf(ulaz,"%d",&niz[i]);
  48.         i++;
  49. } while (c=fgetc(ulaz)!=EOF && i<100);
  50. fclose (ulaz);
  51. fprintf(izlaz,"%d", BrRastucih(niz,i));
  52. fclose(izlaz);
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement