Arreglar radares de tramo
This commit is contained in:
1 parent
6ad15af53b
commit
a01c50d36c
2 files changed
+28
-14
No files matched your search
@@ -1,13 +1,23 @@
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
void main() {
|
||||
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
|
||||
// to see how IntelliJ IDEA suggests fixing it.
|
||||
IO.println(String.format("Hello and welcome!"));
|
||||
import java.util.Scanner;
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
|
||||
IO.println("i = " + i);
|
||||
}
|
||||
}
|
||||
void main() {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
// Coordenadas de las esquinas opuestas
|
||||
int ax, ay, bx, by;
|
||||
// Longitud de lados
|
||||
int l1, l2;
|
||||
// Area del rectangulo
|
||||
int area;
|
||||
while(true) {
|
||||
System.out.print("Introduce las coordenadas del rectángulo (ax ay bx by): ");
|
||||
ax = sc.nextInt();
|
||||
ay = sc.nextInt();
|
||||
bx = sc.nextInt();
|
||||
by = sc.nextInt();
|
||||
// Ternario para obtener resta positiva
|
||||
l1 = (ax < bx) ? bx - ax : ax - bx;
|
||||
l2 = (ay < by) ? by - ay : ay - by;
|
||||
area = l1 * l2;
|
||||
System.out.println("El área es: " + area);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user