Advertisement
Guest User

Untitled

a guest
May 25th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. -----------------------------------------
  2. QUESTAO 1
  3. ---------
  4. typedef struct Ponto
  5. {
  6. float px;
  7. float py;
  8. }Ponto;
  9.  
  10. -----------------------------------------
  11. QUESTAO 2
  12. ---------
  13. void atribuiValorPonto(float a, float b, struct Ponto *p)
  14. {
  15. p->px = a;
  16. p->py = b;
  17. }
  18. -----------------------------------------
  19. QUESTAO 3
  20. ---------
  21. typedef struct Triangulo
  22. {
  23. Ponto a;
  24. Ponto b;
  25. Ponto c;
  26.  
  27. }Triangulo;
  28. -----------------------------------------
  29. QUESTAO 4
  30. ---------
  31. float perimetro_tri(Ponto a, Ponto b, Ponto c)
  32. {
  33. float peri;
  34. float normaAB, normaAC, normaBC;
  35. normaAB = sqrt( pow((b.px - a.px),2) + pow((b.py - a.py),2) );
  36. normaAC = sqrt( pow((c.px - a.px),2) + pow((c.py - a.py),2) );
  37. normaBC = sqrt( pow((c.px - b.px),2) + pow((c.py - b.py),2) );
  38. peri = normaAB + normaAC + normaBC;
  39. return peri;
  40. }
  41. -----------------------------------------
  42. QUESTAO 5
  43. ---------
  44. float area_tri(Ponto a, Ponto b, Ponto c)
  45. {
  46. float area;
  47. float peri;
  48. float normaAB, normaAC, normaBC;
  49. normaAB = sqrt( pow((b.px - a.px),2) + pow((b.py - a.py),2) );
  50. normaAC = sqrt( pow((c.px - a.px),2) + pow((c.py - a.py),2) );
  51. normaBC = sqrt( pow((c.px - b.px),2) + pow((c.py - b.py),2) );
  52. peri = normaAB + normaAC + normaBC;
  53. area = sqrt( (peri/2)*((peri/2) - normaAB)*((peri/2) - normaAC)*((peri/2) - normaBC) );
  54. return area;
  55. }
  56. -----------------------------------------
  57. QUESTAO 6
  58. ---------
  59. int teste_tri(Ponto a, Ponto b, Ponto c)
  60. {
  61. float normaAB, normaAC, normaBC;
  62. normaAB = sqrt( pow((b.px - a.px),2) + pow((b.py - a.py),2) );
  63. normaAC = sqrt( pow((c.px - a.px),2) + pow((c.py - a.py),2) );
  64. normaBC = sqrt( pow((c.px - b.px),2) + pow((c.py - b.py),2) );
  65. if(normaAB == normaAC && normaAC == normaBC){
  66. return 1;
  67. }
  68. else return 0;
  69. }
  70. -----------------------------------------
  71. QUESTAO 7
  72. ---------
  73. typedef struct Circunferencia
  74. {
  75. Ponto centro;
  76. float raio;
  77.  
  78. }Circunferencia;
  79. -----------------------------------------
  80. QUESTAO 8
  81. ---------
  82. float perimetro_circ(Circunferencia a)
  83. {
  84. float perimetro;
  85. perimetro = 2*PI*a.raio;
  86. return perimetro;
  87. }
  88. -----------------------------------------
  89. QUESTAO 9
  90. ---------
  91. float area_circ(Circunferencia a)
  92. {
  93. float area;
  94. area = PI*a.raio*a.raio;
  95. return area;
  96. }
  97. -----------------------------------------
  98. QUESTAO 10
  99. ----------
  100. int verif_circ(Circunferencia c1, Ponto p1)
  101. {
  102. float eq;
  103. eq = pow((p1.px - c1.centro.px),2) + pow((p1.py - c1.centro.py),2);
  104. if(eq == c1.raio*c1.raio) return 1;
  105. else return 0;
  106. }
  107. -----------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement