Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- #include <string>
- #include <sstream>
- using namespace std;
- const double eps = 1e-9;
- struct line {
- double a, b, c;
- };
- double det ( double a, double b, double c, double d) {
- return a * d - b * c;
- }
- void output_line(line &l){
- cout << fixed << setprecision(8) << l.a << " " << l.b << " " << l.c;
- }
- bool parallel ( line m, line n) {
- return abs ( det (m.a, m.b, n.a, n.b)) < eps;
- }
- int main(){
- double a,b,c,r;
- cin >> a >> b >> c >> r;
- line l1,l2,l3,l4;
- l1.a = a;
- l1.b = b;
- l1.c = c;
- l2.a = a+r;
- l2.b = b;
- l2.c = c;
- l3.a = a;
- l3.b = b+r;
- l3.c = c;
- l4.a = a;
- l4.b = b;
- l4.c = c+r;
- if( parallel(l1,l2)){
- if(a+r > a-r){
- output_line(l2);
- cout << endl;
- output_line(l1);
- }
- else {
- output_line(l1);
- cout << endl;
- output_line(l2);
- }
- }
- else if(parallel(l1,l3)){
- if(b+r > b-r){
- output_line(l2);
- cout << endl;
- output_line(l1);
- }
- else {
- output_line(l1);
- cout << endl;
- output_line(l2);
- }
- }
- else if(parallel(l1,l4)){
- if(c+r > c-r){
- output_line(l2);
- cout << endl;
- output_line(l1);
- }
- else {
- output_line(l1);
- cout << endl;
- output_line(l2);
- }
- }
- /*stringstream s;
- s << fixed << setprecision(9) << ans;
- string a = s.str();
- a = a.substr(0, a.length()-1);
- cout << a;*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement