Está en la página 1de 12

11172 - Relational Operator

Algunos operadores verifican la relación entre dos valores y estos operadores se llaman relacionales
operadores. Teniendo en cuenta dos valores numéricos, su trabajo es solo para descubrir la relación
entre ellos
es decir (i) El primero es mayor que el segundo (ii) El primero es menor que el segundo o (iii) Primero y
el segundo es igual.

Entrada
La primera línea del archivo de entrada es un entero t (t <15) que indica cuántos conjuntos de entradas
hay.
Cada una de las siguientes líneas t contiene dos enteros a y b (| a |, | b | <1000000001).

Salida
Para cada línea de entrada produce una línea de salida. Esta línea contiene cualquiera de los
operadores relacionales
'>', '<' O '=', que indica la relación que es apropiada para los dos números dados.

Entrada de muestra
3
10 20
20 10
10 10

Muestra de salida
<
>
=
SOLUCION.:

import java.util.Scanner;
public class proble {
public static void main(String[] args) {
Scanner lee = new Scanner(System.in);
int a, b, n;
n = lee.nextInt();
for (int i = 1; i <= n; i++) {
a = lee.nextInt();
b = lee.nextInt();
if (a < b) {
System.out.println("<");
}

if (a > b) {
System.out.println(">");
}

if (a == b) {
System.out.println("=");
}
}
}
}
11727 - Cost Cutting

La empresa XYZ ha sido muy golpeada por la recesión y está tomando muchas medidas de
reducción de costos. Algunas de estas medidas incluyen renunciar a espacio de oficina, ir a
código abierto, reducir incentivos, recortando lujos y lanzando billetes rosas.
Tienen tres (3) empleados trabajando en las cuentas departamento y van a despedir a dos (2)
de ellos. Después de serie de reuniones, han decidido desalojar a la persona quién recibe el
mayor salario y el que menos recibe. Esta suele ser la tendencia general durante una crisis
como esta. Se te darán los salarios de estos 3 empleados que trabajan en el departamento de
cuentas. Tienes que averiguar el salario de la persona que sobrevive.

Entrada
La primera línea de entrada es un número entero T (T <20) que indica el número de casos de
prueba. Cada caso
consiste en una línea con 3 enteros positivos distintos. Estos 3 enteros representan los salarios
de los tres
empleados. Todos estos enteros estarán en el rango [1000, 10000].

Salida
Para cada caso, muestre el número de caso seguido del salario de la persona que sobrevive.

Entrada de muestra
3
1000 2000 3000
3000 2500 1500
1500 1200 1800

Muestra de salida
Caso 1: 2000
Caso 2: 2500
Caso 3: 1500
SOLUCION.:

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int a, b, c, n;
Scanner lee = new Scanner(System.in);
n = lee.nextInt();
for (int i = 1; i <= n; i++) {
a = lee.nextInt();
b = lee.nextInt();
c = lee.nextInt();
System.out.println("\n" + "Case " + i + ": "
+ ((b < a && a < c) || (c < a && a < b) ? a : ((a < b && b < c)
|| (c < b && b < a) ? b : c)));
}
}
}
11498 - Division of Nlogonia
After centuries of hostilities and skirmishes between the four nations living in the land generally known
as Nlogonia, and years of negotiations involving diplomats, politicians and the armed forces of all
interested parties, with mediation by UN, NATO, G7 and SBC, it was at last agreed by all the way to
end the dispute, dividing the land into four independent territories.
It was agreed that one point, called division point, with coordinates established in the negotiations,
would de_ne the country division, in the following way. Two lines, both containing the division point,
one in the North-South direction and one in the East-West direction, would be drawn on the map,
dividing the land into four new countries. Starting from the Western-most, Northern-most quadrant,
in clockwise direction, the new countries will be called Northwestern Nlogonia, Northeastern Nlogonia,
Southeastern Nlogonia and Southwestern Nlogonia.
The UN determined that a page in the Internet should exist so that the inhabitants could check in
which of the countries their homes are. You have been hired to help implementing the system.
Input
The input contains several test cases. The _rst line of a test case contains one integer K indicating
the number of queries that will be made (0 < K _ 103). The second line of a test case contains two
integers N and M representing the coordinates of the division point (􀀀104 < N;M < 104). Each
of the K following lines contains two integers X and Y representing the coordinates of a residence
(􀀀104 _ X; Y _ 104).
The end of input is indicated by a line containing only the number zero.
Output
For each test case in the input your program must print one line containing:
_ the word `divisa' (means border in Portuguese) if the residence is on one of the border lines
(North-South or East-West);
_ `NO' (means NW in Portuguese) if the residence is in Northwestern Nlogonia;
_ `NE' if the residence is in Northeastern Nlogonia;
_ `SE' if the residence is in Southeastern Nlogonia;
_ `SO' (means SW in Portuguese) if the residence is in Southwestern Nlogonia.
Sample Input
3
21
10 10
-10 1
0 33
4
-1000 -1000
-1000 -1000
00
-2000 -10000
-999 -1001
0
Sample Output
NE
divisa
NO
divisa
NE
SO
SE
Solución.-

import java.io.PrintWriter;
import java.util.Scanner;
public class uvasss {
public static void main(String[] args) {
Scanner lee = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int SW = 0;
do {
SW = lee.nextInt();
if (SW == 0)
break;
int N = lee.nextInt();
int M = lee.nextInt();

for (int i = 0; i < SW; i++) {


int X = lee.nextInt();
int Y = lee.nextInt();

if (X == N || Y == M)
out.println("divisa");
else if (X > N && Y > M)
out.println("NE");
else if (X < N && Y > M)
out.println("NO");
else if (X < N && Y < M)
out.println("SO");
else
out.println("SE");
}

} while (SW != 0);


out.close(); }

}
264 - Count on Cantor
Solucion.-

import java.util.Scanner;
public class uvasss {
public static void main(String[] args) {

int n, SW, sum;


Scanner in = new Scanner(System.in);

while (in.hasNext()) {

n = in.nextInt();
for (SW=1, sum = 0;(sum+=SW)<n;SW++) {}
if ((SW&1)==1)
System.out.println("TERM " + n + " IS " +(1+(sum-n))+"/" + (
SW-(sum-n)));
else
System.out.println("TERM " + n + " IS " + (SW-(sum-n))+ "/" +(1+(sum-n)));
}

}}

También podría gustarte