Advertisement
Guest User

ass

a guest
Aug 28th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. # include <stdlib.h>
  2. # include <stdio.h>
  3. typedef struct{
  4. int id_uni, n_alunos;
  5. } Tuni; //typedef universidade
  6.  
  7. typedef struct{
  8. int id_uni, id_aluno;
  9. }Tal; //typedef aluno
  10.  
  11. void Ler_int(int *i){ //le um inteiro
  12. scanf("%d", i);
  13. }
  14.  
  15. void Ler_vet(Tuni *x, int y){//le inputs no vetor y vezes
  16. int i;
  17. for(i=0;i<y;i++)
  18. scanf("%d %d", x[i].id_uni, x[i].n_alunos);
  19.  
  20. }
  21.  
  22. int main(void){
  23. Tuni *p;//vetor p/ universidades
  24. Tal *v; //vetor p/ alunos
  25. int n, i;
  26. Ler_int( &n);
  27. p = (Tuni*)malloc(n*sizeof(Tuni));
  28. Ler_vet(p, n);
  29. for (i=0;i<n;i++)
  30. printf("%d %d", p[i].id_uni, p[i].n_alunos);
  31.  
  32. free(p);
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement