-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
404 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// TODO: complete os espaços em branco com sua solução para o problema | ||
// Abaixo segue um exemplo de código que você pode ou não utilizar | ||
import java.util.*; | ||
|
||
public class DIO{ | ||
|
||
public static void main(String[] args) { | ||
|
||
//a classe Scanner auxilia na leitura dos dados de entrada | ||
Scanner leitor = new Scanner(System.in); | ||
|
||
int QT = Integer.parseInt(leitor.nextLine()); | ||
|
||
String linha1[], linha2[], nome1, escolha1, nome2, escolha2; | ||
int N, M; | ||
|
||
for (int i = 0; i < QT; i++) { | ||
|
||
//quebra string em várias substrings a partir de um caracter | ||
linha1 = leitor.nextLine().split(" "); | ||
linha2 = leitor.nextLine().split(" "); | ||
|
||
|
||
N = Integer.parseInt(linha2[0]); | ||
M = Integer.parseInt(linha2[1]); | ||
|
||
nome1 = linha1[0]; | ||
escolha1 = linha1[1]; | ||
|
||
nome2 = linha1[2]; | ||
escolha2 = linha1[3]; | ||
|
||
if (((N + M) % 2 == 0 && escolha1.equalsIgnoreCase("PAR")) || | ||
((N + M) % 2 != 0 && escolha1.equalsIgnoreCase("IMPAR"))) System.out.println(nome1); | ||
else System.out.println(nome2); | ||
} | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
Desafios-de-Codigo/Desafios-TQI-Java/DistanciaEntreDoisPontos.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import java.util.Scanner; | ||
|
||
public class DistanciaEntreDoisPontos{ | ||
|
||
public static void main(String[] args){ | ||
Scanner teclado = new Scanner(System.in); | ||
|
||
double x1 = teclado.nextDouble(); | ||
double y1 = teclado.nextDouble(); | ||
double x2 = teclado.nextDouble(); | ||
double y2 = teclado.nextDouble(); | ||
|
||
double distancia = Math.sqrt(Math.pow((x2 - x1), 2) + Math.pow((y2 - y1), 2)); // Calcula o valor da distância usando a fórmula | ||
|
||
System.out.println(String.format("%.4f", distancia)); // Com 4 casas após o ponto decial | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import java.io.IOException; | ||
import java.util.Scanner; | ||
|
||
public class DIO { | ||
|
||
//complete o código para que ele funcione corretamente | ||
|
||
public static void main(String[] args) throws IOException { | ||
//a classe Scanner auxilia na leitura dos dados de entrada | ||
Scanner leitor = new Scanner(System.in); | ||
|
||
while (true) { | ||
int N = leitor.nextInt(); | ||
int M = leitor.nextInt(); | ||
int troco = M - N; | ||
int[] notas = {2, 5, 10, 20, 50, 100}; | ||
boolean possivel = false; | ||
|
||
if (N == 0 && M == 0){ | ||
break; | ||
} | ||
|
||
for (int i = 0; i < 6; i++) { | ||
for (int j = 0; j < 6; j++) { | ||
if (troco - notas[j] == notas[i]){ | ||
possivel = true; | ||
} | ||
} | ||
} | ||
|
||
if (possivel){ | ||
System.out.println("possible"); | ||
} | ||
else{ | ||
System.out.println("impossible"); | ||
} | ||
} | ||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
Desafios-de-Codigo/Desafios-TQI-Java/ProibidoAEntradaDeMenores.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import java.util.*; | ||
|
||
public class DIO{ | ||
|
||
public static void main(String[] args) { | ||
|
||
Scanner scan = new Scanner(System.in); | ||
|
||
int N= scan.nextInt(); | ||
|
||
String string = scan.nextLine(); | ||
|
||
//String[] s = string.split(" "); | ||
|
||
|
||
double[] idade = new double[N]; | ||
|
||
for (int i = 0; i < N; i++) | ||
{ | ||
string = scan.nextLine(); | ||
idade[i] = Integer.parseInt(string); | ||
} | ||
|
||
System.out.println("Nao poderao entrar as idades: "); | ||
|
||
for (int i = 0; i < N; i++) | ||
{ | ||
if(idade[i] < 18) { | ||
System.out.println((int) idade[i]); | ||
} | ||
} | ||
|
||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
Desafios-de-Codigo/Desafios-TQI-Java/QuemPagaraAConta.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import java.io.IOException; | ||
import java.util.*; | ||
|
||
|
||
public class DIO{ | ||
|
||
//complete o código para que ele funcione corretamente | ||
|
||
public static void main(String[] args) throws IOException { | ||
|
||
//a classe Scanner auxilia na leitura dos dados de entrada | ||
Scanner input = new Scanner(System.in); | ||
|
||
while(input.hasNext()){ | ||
int entrada = input.nextInt(); | ||
|
||
if (entrada % 2 == 0) { | ||
System.out.println(0); | ||
} else { | ||
System.out.println(1); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.