Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- typedef struct{
- int redBr;
- char ime_prezime[50];
- int visina[3];
- }at_vis;
- void Unos(at_vis *, int);
- int main()
- {
- at_vis *a;
- FILE *f;
- f=fopen("atletika.txt","w");
- int n;
- printf("Broj natjecatelja:");
- scanf("%d", &n);
- a =(at_vis*)malloc(n*sizeof(at_vis));
- Unos(a,n);
- fprintf(f,"REDNI BROJ\t IME\t SPLIT OSLO TOKIO\n");
- for (int i=0;i<n;i++)
- {
- fprintf(f,"\n%d\t", a[i].redBr);
- fprintf(f,"%s\t", a[i].ime_prezime);
- for(int j=0;j<3;j++)
- {
- fprintf(f,"%d ", a[i].visina[j]);
- }
- }
- fclose(f);
- }
- void Unos(at_vis *a, int n)
- {
- for(int i=0;i<n;i++)
- {
- printf("%d. natjecatelj:", i+1);
- printf("Redni broj:");
- scanf("%d", &a[i].redBr);
- printf("Ime:");
- scanf("%s", a[i].ime_prezime);
- for(int j=0;j<3;j++)
- {
- printf("%d. visina", j+1);
- scanf("%d", &a[i].visina[j]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment