Advertisement
hmcristovao

Exercício 10 da lista 06

Jul 16th, 2013
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define MAX_PONTOS 400
  4. #define MAX_FIGURAS 3
  5.  
  6. struct TipoPonto {
  7.    float x, y;
  8.    int ordem;
  9. };
  10.  
  11. struct TipoFigura {
  12.    int qtdePontos;
  13.    struct TipoPonto pontos[MAX_PONTOS];
  14. };
  15.  
  16.  
  17. int main() {
  18.    struct TipoFigura figuras[MAX_FIGURAS];
  19.  
  20.    int i, j;
  21.    for(i=0; i<MAX_FIGURAS; i++) {
  22.       printf("Quantos pontos da figura no %d", i+1);
  23.       scanf("%d", &figuras[i].qtdePontos);
  24.       for(j=0; j<figuras[i].qtdePontos; j++) {
  25.          printf("Entre com as coordenadas x, y e a a ordem: ");
  26.          scanf("%f %f %d", &figuras[i].pontos[j].x,
  27.                            &figuras[i].pontos[j].y,
  28.                            &figuras[i].pontos[j].ordem);
  29.       }
  30.    }
  31.    printf("\nDados cadastrados:");
  32.    for(i=0; i<MAX_FIGURAS; i++) {
  33.       printf("\nFigura no %d: ", i+1);
  34.       for(j=0; j<figuras[i].qtdePontos; j++) {
  35.          printf("\nponto no %d (%f,%f) ordem: %d",
  36.                 j+1, figuras[i].pontos[j].x,
  37.                      figuras[i].pontos[j].y,
  38.                      figuras[i].pontos[j].ordem);
  39.       }
  40.    }
  41.  
  42.    return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement