Three real numbers are given. Find their pairwise sums.
Input. Three real numbers x, y, z.
Output. Print in one line
the sums x + y, x + z and y + z with 4 decimal digits.
Sample
input |
Sample
output |
1.2345 3.4566 -0.1236 |
4.6911 1.1109 3.3330 |
real numbers
In this problem you should read three real numbers and print three sums.
Algorithm realization
Read three real numbers.
scanf("%lf %lf %lf", &x, &y, &z);
Print the required sums.
printf("%.4lf %.4lf
%.4lf\n", x + y, x + z,
y + z);
Java realization
import java.util.*;
public class Main
{
public static void
main(String[] args)
{
Scanner con = new
Scanner(System.in);
double x = con.nextDouble();
double y = con.nextDouble();
double z = con.nextDouble();
System.out.printf("%.4f
%.4f %.4f\n",x + y,x + z,y + z);
con.close();
}
}
Java realization – class MyDouble
import java.util.*;
class MyDouble
{
private double a;
MyDouble(double a)
{
this.a = a;
}
MyDouble Add(MyDouble
b)
{
return new MyDouble(a + b.a);
}
public String
toString()
{
return String.format("%.4f", a);
}
}
public class Main
{
public static void
main(String[] args)
{
Scanner con = new
Scanner(System.in);
MyDouble x = new MyDouble(con.nextDouble());
MyDouble y = new MyDouble(con.nextDouble());
MyDouble z = new MyDouble(con.nextDouble());
System.out.println(x.Add(y) + "
" + x.Add(z) + " " + y.Add(z));
con.close();
}
}
Python realization
x, y, z = map(float, input().split())
print(x + y, x + z, y + z)