BetinaUKTC

8.1

Dec 24th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.37 KB | None | 0 0
  1. ЛИЦЕ НА ТРИЪГЪЛНИК В РАВНИНА
  2. import java.util.Scanner;
  3.  
  4. public class main {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.         int x1 = Integer.parseInt(scan.nextLine());
  9.         int y1 = Integer.parseInt(scan.nextLine());
  10.         int x2 = Integer.parseInt(scan.nextLine());
  11.         int y2 = Integer.parseInt(scan.nextLine());
  12.         int x3 = Integer.parseInt(scan.nextLine());
  13.         int y3=y2;
  14.         int a = Math.abs(x2-x3);
  15.         int h = Math.abs(y2-y1);
  16.         double S = (double)a*h/2;
  17.         System.out.println(S);
  18.     }
  19. }
  20. ПРЕНАСЯНЕ НА ТУХЛИ
  21. import java.util.Scanner;
  22.  
  23. public class main {
  24.  
  25.     public static void main(String[] args) {
  26.         Scanner scan = new Scanner(System.in);
  27.         int bricks = Integer.parseInt(scan.nextLine());
  28.         int workers = Integer.parseInt(scan.nextLine());
  29.         int comp = Integer.parseInt(scan.nextLine());
  30.         int bricksPerWorker= bricks/workers;
  31.         double courses = Math.ceil((double)bricksPerWorker/comp);
  32.         if(courses == 0) {
  33.             courses = 1;
  34.         }
  35.         System.out.printf("%.0f",courses);
  36.     }
  37. }
  38.  
  39. ТОЧКА ОТ ОТСЕЧКА
  40. import java.util.Scanner;
  41.  
  42. public class main {
  43.  
  44.     public static void main(String[] args) {
  45.         Scanner scan = new Scanner(System.in);
  46.         int first = Integer.parseInt(scan.nextLine());
  47.         int second = Integer.parseInt(scan.nextLine());
  48.         int point = Integer.parseInt(scan.nextLine());
  49.         int closest = Math.min(Math.abs(first - point),Math.abs(second - point));
  50.         if(point<=first && point>=second) {
  51.             System.out.println("in");
  52.         }else {
  53.             System.out.println("out");
  54.         }
  55.         System.out.println(closest);
  56.     }
  57. }
  58.  
  59. ТОЧКА ВЪВ ФИГУРА
  60. import java.util.Scanner;
  61.  
  62. public class main {
  63.  
  64.     public static void main(String[] args) {
  65.         Scanner scan = new Scanner(System.in);
  66.         int x = Integer.parseInt(scan.nextLine());
  67.         int y = Integer.parseInt(scan.nextLine());
  68.         if((x>=4 && x<=10 && y>=-5 && y<=3) || (x>= 2 && x<= 12 && y>=-3 && y<=1)) {
  69.             System.out.println("in");
  70.         }else {
  71.             System.out.println("out");
  72.         }
  73.     }
  74. }
  75. ДАТА СЛЕД 5 ДНИ
  76. import java.util.Scanner;
  77.  
  78. public class main {
  79.  
  80.     public static void main(String[] args) {
  81.         Scanner scan = new Scanner(System.in);
  82.         int d = Integer.parseInt(scan.nextLine());
  83.         int m = Integer.parseInt(scan.nextLine());
  84.         int dayInMounts = 31;
  85.         d+=5;
  86.         if(m==4 || m==6 || m==9 || m==11) {
  87.             dayInMounts = 30;
  88.         }
  89.         if(m==2) {
  90.             dayInMounts = 28;
  91.         }
  92.        
  93.         if(d>=dayInMounts) {
  94.             d = d - dayInMounts;
  95.             m+=1;
  96.         }
  97.         if(m>=12) {
  98.             m=1;
  99.         }
  100.  
  101.        
  102.         System.out.printf("%d.%02d",d,m);
  103.     }
  104. }
  105. СУМА ОТ ТРИ ЧИСЛА
  106. import java.util.Scanner;
  107.  
  108. public class main {
  109.  
  110.     public static void main(String[] args) {
  111.         Scanner scan = new Scanner(System.in);
  112.         int a = Integer.parseInt(scan.nextLine());
  113.         int b = Integer.parseInt(scan.nextLine());
  114.         int c = Integer.parseInt(scan.nextLine());
  115.         if (a + b == c) {
  116.             if (a < b) {
  117.                 System.out.printf("%d + %d = %d", a, b, c);
  118.             }if(a>b) {
  119.                 System.out.printf("%d + %d = %d", b, a, c);
  120.             }
  121.         }
  122.         else if (a + c == b) {
  123.             if (a < c) {
  124.                 System.out.printf("%d + %d = %d", a, c, b);
  125.             }if(a>c) {
  126.                 System.out.printf("%d + %d = %d", c, a, b);
  127.             }
  128.         }
  129.         else if (b + c == a) {
  130.             if (b < c) {
  131.                 System.out.printf("%d + %d = %d", b, c, a);
  132.             }if(b>c) {
  133.                 System.out.printf("%d + %d = %d", c, b, a);
  134.             }
  135.         }else {
  136.             System.out.println("No");
  137.         }
  138.    
  139.     }
  140. }
Add Comment
Please, Sign In to add comment