Advertisement
Guest User

Untitled

a guest
May 25th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4. #include <string>
  5. #include <sstream>
  6. using namespace std;
  7. const double eps = 1e-9;
  8. struct line {
  9. double a, b, c;
  10. };
  11. double det ( double a, double b, double c, double d) {
  12.     return a * d - b * c;
  13. }
  14. void output_line(line &l){
  15.     cout << fixed << setprecision(8) << l.a << " " << l.b << " " << l.c;
  16.  
  17. }
  18. bool parallel ( line m, line n) {
  19.     return abs ( det (m.a, m.b, n.a, n.b)) < eps;
  20. }
  21.  
  22. int main(){
  23.     double a,b,c,r;
  24.     cin >> a >> b >> c >> r;
  25.     line l1,l2,l3,l4;
  26.     l1.a = a;
  27.     l1.b = b;
  28.     l1.c = c;
  29.    
  30.     l2.a = a+r;
  31.     l2.b = b;
  32.     l2.c = c;
  33.    
  34.     l3.a = a;
  35.     l3.b = b+r;
  36.     l3.c = c;
  37.    
  38.     l4.a = a;
  39.     l4.b = b;
  40.     l4.c = c+r;
  41.     if( parallel(l1,l2)){
  42.         if(a+r > a-r){
  43.             output_line(l2);
  44.             cout << endl;
  45.             output_line(l1);
  46.         }
  47.         else {
  48.             output_line(l1);
  49.             cout << endl;
  50.             output_line(l2);
  51.         }
  52.     }
  53.     else if(parallel(l1,l3)){
  54.         if(b+r > b-r){
  55.                 output_line(l2);
  56.                 cout << endl;
  57.                 output_line(l1);
  58.         }
  59.         else {
  60.                 output_line(l1);
  61.                 cout << endl;
  62.                 output_line(l2);
  63.              }
  64.     }
  65.     else if(parallel(l1,l4)){
  66.         if(c+r > c-r){
  67.                 output_line(l2);
  68.                 cout << endl;
  69.                 output_line(l1);
  70.                
  71.             }
  72.             else {
  73.                 output_line(l1);
  74.                 cout << endl;
  75.                 output_line(l2);
  76.             }
  77.     }
  78.    
  79.    
  80.    
  81.    
  82.     /*stringstream s;
  83.     s << fixed << setprecision(9) << ans;
  84.     string a = s.str();
  85.     a = a.substr(0, a.length()-1);
  86.     cout << a;*/
  87.    
  88.     return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement