Advertisement
Josif_tepe

Untitled

Jan 18th, 2024
620
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.69 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.    
  8.     FILE *in = fopen("input.txt", "r");
  9.     FILE * out = fopen("output.txt", "w");
  10.  
  11.     if(in == NULL) {
  12.         printf("Fajlot ne postoi\n");
  13.         return 0;
  14.     }
  15.     if(out == NULL) {
  16.         printf("Fajlot ne postoin\n");
  17.         return 0;
  18.     }
  19.     char s[1000];
  20.     int a, b, c;
  21.     int brojac = 0;
  22.     while(fscanf(in, "%s%d%d%d", s, &a, &b, &c) != EOF) {
  23.         int prosek = (a + b + c) / 3;
  24.         if(prosek < 10) {
  25.             fprintf(out, "%s %d\n", s, prosek);
  26.             brojac++;
  27.         }
  28.     }
  29.     fprintf(out, "%d\n", brojac);
  30.    
  31.     return 0;
  32. }
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement