Guest User

Untitled

a guest
Oct 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdio>
  4. using namespace std;
  5.  
  6. /*
  7. Calcule o volume através da área dos pontos ( utilizando o produto vetorial ) e da largura.
  8. Depois divida esse volume total pelo volume de uma unidade, (pi*r*r) e pegue o chão disso.
  9. */
  10. int main(){
  11. //Poligono
  12. double larg, x0, y0, x1, y1, x2, y2, area, areaT;
  13. //Hole
  14. double raio, largH;
  15. int poligonos;
  16.  
  17. while( cin >> poligonos && poligonos ){
  18. areaT = 0;
  19.  
  20. for( int i = 0; i < poligonos; ++i ){
  21. area = 0;
  22. cin >> larg >> x0 >> y0;
  23. cin >> x2 >> y2;
  24. x1 = x0;
  25. y1 = y0;
  26. while( x2 != x0 || y2 != y0 ){
  27. area += ( x1 * y2 - x2 * y1 );
  28. x1 = x2;
  29. y1 = y2;
  30. cin >> x2 >> y2;
  31. }
  32. area += ( x1 * y2 - x2 * y1 );
  33.  
  34. if( area < 0 )
  35. area *= -1;
  36. areaT += ( area * larg ) / 2;
  37. }
  38. cin >> raio >> largH;
  39. double resposta = areaT / ( M_PI * raio * raio * largH );
  40. cout << floor( resposta ) << endl;
  41. }
  42.  
  43. }
Add Comment
Please, Sign In to add comment