Advertisement
Josif_tepe

Untitled

Jan 18th, 2024
578
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4.  
  5. int main(int argc, const char * argv[]) {
  6.  
  7.     if(argc < 3) {
  8.         printf("Vlezna  datoteka i izlezna treba da se vnesat kako argument\n");
  9.         return 0;
  10.     }
  11.     FILE *in = fopen(argv[1], "r");
  12.     FILE * out = fopen(argv[2], "w");
  13.  
  14.     if(in == NULL) {
  15.         printf("Fajlot ne postoi\n");
  16.         return 0;
  17.     }
  18.     if(out == NULL) {
  19.         printf("Fajlot ne postoin\n");
  20.         return 0;
  21.     }
  22.     char s[1000];
  23.     int a, b, c;
  24.     int brojac = 0;
  25.     while(fscanf(in, "%s%d%d%d", s, &a, &b, &c) != EOF) {
  26.         int prosek = (a + b + c) / 3;
  27.         if(prosek < 10) {
  28.             fprintf(out, "%s %d\n", s, prosek);
  29.             brojac++;
  30.         }
  31.     }
  32.     fprintf(out, "%d\n", brojac);
  33.    
  34.     return 0;
  35. }
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement