Commit 1a35f7bc by edtell

Update KT1.c

parent 44215698
Showing with 3 additions and 68 deletions
#include <stdio.h>
#include <stdlib.h>
typedef struct {
char nimi[32];
int kood;
int hinne[4];
} Inim;
void input(FILE *sisse, Inim *);
void stip(FILE *valja, Inim *, int);
void fnimi(char*, char*);
int loe(FILE *sisse);
#include "funkts.c"
int main( void ){
int N = 0;
......@@ -58,58 +46,4 @@ Inim nimekiri[N];
fclose(valja);
return 0;
}
void input(FILE *sisse, Inim *keegi) // Viit muutujale keegi
{
fscanf(sisse,"%s %d %d,%d,%d,%d\n", keegi->nimi, &keegi[0].kood, &keegi[0].hinne[0], &keegi[0].hinne[1], &keegi[0].hinne[2], &keegi[0].hinne[3]);
}
void stip(FILE *valja, Inim *keegi, int N){
for(int i=0; i<N;i++){
if(keegi[i].hinne[0] == 5 && keegi[i].hinne[1] == 5 && keegi[i].hinne[2] == 5 && keegi[i].hinne[3] == 5){
fprintf(valja, "%s %d %d\n", keegi[i].nimi,keegi[i].kood, 100);
}
else if(keegi[i].hinne[0] >= 4 && keegi[i].hinne[1] >= 4 && keegi[i].hinne[2] >= 4 && keegi[i].hinne[3] >= 4){
fprintf(valja, "%s %d %d\n", keegi[i].nimi,keegi[i].kood, 75);
}
else{
fprintf(valja, "%s %d %d\n", keegi[i].nimi,keegi[i].kood, 0);
}
}
if(!feof(valja)){
printf("Tehtud!\n");
printf("Kontrolllige Output faili");
}
}
void fnimi(char *nimi, char *tekst){
printf("%s", tekst);
scanf("%s", nimi);
}
int loe(FILE *sisse){
int i = 0;
char buff[59];
int buff2, buff3[4];
while(fscanf(sisse,"%s %d %d,%d,%d,%d", buff, &buff2, &buff3[0], &buff3[1], &buff3[2], &buff3[3]) !=EOF){
i++;
}
rewind(sisse);
return i;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment