Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct student
- {
- char nazwisko[20];
- char imie[20];
- int numer;
- double oceny[5];
- double srednia;
- };
- void dopisz(char*nazwa);
- struct student srednia(struct student s);
- void drukuj (struct student s);
- void wydruk (char*nazwa);
- int main()
- {
- }
- void dopisz(char*nazwa)
- {
- FILE*plik=fopen(nazwa,"lista");
- int i=0;
- struct student s;
- fflush(stdin);
- printf("Podaj nazwisko");
- scanf("%29[^\n]s",s.nazwisko);
- fflush(stdin);
- printf("Podaj imie");
- scanf("%19[^\n]s", s.imie);
- fflush(stdin);
- printf("Podaj numer");
- scanf("%d ", &s.numer);
- fflush(stdin);
- for(i=0;i<=5;i++)
- {
- printf("podaj %d ocene", i);
- scanf("%d", &s.oceny+i);
- }
- s=srednia(s);
- fwrite(&s, sizeof(struct student),1,plik);
- fclose(plik);
- }
- struct student srednia(struct student s)
- {
- int i=0;
- double suma=0;
- for(i=0;i<=5;i++)
- {
- suma+=*s.oceny+i;
- }
- s.srednia=suma/5;
- return s;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement