Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <stdlib.h>
- # include <stdio.h>
- typedef struct{
- int id_uni, n_alunos;
- } Tuni; //typedef universidade
- typedef struct{
- int id_uni, id_aluno;
- }Tal; //typedef aluno
- void Ler_int(int *i){ //le um inteiro
- scanf("%d", i);
- }
- void Ler_vet(Tuni *x, int y){//le inputs no vetor y vezes
- int i;
- for(i=0;i<y;i++)
- scanf("%d %d", x[i].id_uni, x[i].n_alunos);
- }
- int main(void){
- Tuni *p;//vetor p/ universidades
- Tal *v; //vetor p/ alunos
- int n, i;
- Ler_int( &n);
- p = (Tuni*)malloc(n*sizeof(Tuni));
- Ler_vet(p, n);
- for (i=0;i<n;i++)
- printf("%d %d", p[i].id_uni, p[i].n_alunos);
- free(p);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement