Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- import java.util.Scanner;
- import static java.lang.Math.sqrt;
- public class Main {
- public static void main(String[] args) throws FileNotFoundException {
- int a,b,c;
- double P,p,square;
- File file = new File("input.txt");
- File file2 = new File("output.txt");
- Scanner s = new Scanner(file);
- a = s.nextInt();
- b = s.nextInt();
- c = s.nextInt();
- PrintWriter pw = new PrintWriter(file2);
- if (a+b > c && b+c > a && a+c > b){
- P = a+b+c;
- p = P/2;
- square = sqrt(p*(p-a)*(p-b)*(p-c));
- String string = String.format("%8.5f", square).replace(',', '.');
- pw.print(P+" "+string);
- } else pw.print(-1);
- pw.close();
- }
- }
- var a,b,c:integer;
- p,p1,square:real;
- input :text;
- output :text;
- begin
- assign(input,'input.txt');
- assign(output,'output.txt');
- reset(input);
- rewrite(output);
- read(input,a);
- read(input,b);
- read(input,c);
- if (a+b>c)and(b+c>a)and(a+c>b) then
- begin
- p := a+b+c;
- p1 := p/2;
- square := sqrt(p1*(p1-a)*(p1-b)*(p1-c));
- write(output,p,' ',square:6:5);
- end else write(output,'-1');
- close(output);
- close(input);
- end.
Add Comment
Please, Sign In to add comment