Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
- #include <stdlib.h>
- int main(int argc, const char * argv[]) {
- if(argc < 3) {
- printf("Vlezna i izlezna se vnesuvaat kako argumenti\n");
- return 0;
- }
- FILE *in = fopen(argv[1], "r");
- FILE *out = fopen(argv[2], "w");
- if(in == NULL) {
- printf("Ne validna vlezna datoteka\n");
- return 0;
- }
- if(out == NULL) {
- printf("Ne validna izlezna datoteka\n");
- }
- char ime[1000];
- int a, b, c, d;
- int brojac = 0;
- while(fscanf(in, "%s%d%d%d%d", ime, &a, &b, &c, &d) != EOF) {
- float prosek = (float) (a + b + c + d) / 4.0;
- if(prosek > 5) {
- fprintf(out, "%s %f\n", ime, prosek);
- brojac++;
- }
- }
- fprintf(out, "%d\n", brojac);
- return 0;
- }
- /*
- 7
- 7 2 -1 0 -30 2 -15
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement