Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. struct carnaval
  4. {
  5. char nome [10];
  6. char cor [10];
  7. int quantidade;
  8. };
  9.  
  10.  
  11. int main ()
  12. {
  13. int x=1;
  14.  
  15. struct carnaval blocos[2];
  16. void listar();
  17. void incluir();
  18. void buscar();
  19.  
  20. while (x!=0)
  21. {
  22.  
  23. printf ("1) Incluirn");
  24. printf ("2) Listarn");
  25. printf ("3) Buscarn");
  26. printf ("0) Sairn");
  27.  
  28. scanf ("%d", &x);
  29.  
  30. if (x==0)
  31. {
  32. break;
  33. }
  34. switch (x)
  35. {
  36. case 1:
  37. incluir (blocos);
  38. break;
  39. case 2:
  40. listar (blocos);
  41. break;
  42. case 3:
  43. buscar ();
  44. break;
  45. case 0:
  46. break;
  47. default:
  48. printf ("valor inválidon");
  49. break;
  50. }
  51. }
  52. }
  53.  
  54. void incluir (struct carnaval *incluido[])
  55. {
  56. int i;
  57. for (i=0; i<2; i++)
  58. {
  59. getchar();
  60. fgets ((*incluido)[i].nome, 10, stdin);
  61. fgets ((*incluido)[i].cor, 10, stdin);
  62. scanf ("%d", &(*incluido)[i].quantidade);
  63. }
  64.  
  65. }
  66.  
  67. void listar (struct carnaval print[])
  68. {
  69. int y;
  70.  
  71. for (y=0; y<2; y++)
  72. {
  73. printf ("n%s", print[y].nome);
  74. printf ("%s", print[y].cor);
  75. printf ("%dnn", print[y].quantidade);
  76. }
  77. }
  78.  
  79. void buscar ()
  80. {
  81. printf ("testen");
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement