Guest User

Untitled

a guest
Jan 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.io.PrintWriter;
  4. import java.util.Scanner;
  5.  
  6. import static java.lang.Math.sqrt;
  7.  
  8. public class Main {
  9. public static void main(String[] args) throws FileNotFoundException {
  10. int a,b,c;
  11. double P,p,square;
  12. File file = new File("input.txt");
  13. File file2 = new File("output.txt");
  14. Scanner s = new Scanner(file);
  15. a = s.nextInt();
  16. b = s.nextInt();
  17. c = s.nextInt();
  18. PrintWriter pw = new PrintWriter(file2);
  19. if (a+b > c && b+c > a && a+c > b){
  20. P = a+b+c;
  21. p = P/2;
  22.  
  23. square = sqrt(p*(p-a)*(p-b)*(p-c));
  24.  
  25. String string = String.format("%8.5f", square).replace(',', '.');
  26. pw.print(P+" "+string);
  27.  
  28. } else pw.print(-1);
  29. pw.close();
  30. }
  31.  
  32. }
  33.  
  34. var a,b,c:integer;
  35. p,p1,square:real;
  36. input :text;
  37. output :text;
  38. begin
  39. assign(input,'input.txt');
  40. assign(output,'output.txt');
  41. reset(input);
  42. rewrite(output);
  43. read(input,a);
  44. read(input,b);
  45. read(input,c);
  46. if (a+b>c)and(b+c>a)and(a+c>b) then
  47. begin
  48. p := a+b+c;
  49. p1 := p/2;
  50. square := sqrt(p1*(p1-a)*(p1-b)*(p1-c));
  51. write(output,p,' ',square:6:5);
  52. end else write(output,'-1');
  53. close(output);
  54. close(input);
  55.  
  56. end.
Add Comment
Please, Sign In to add comment