Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Quiz 2 - Semana 7 - RA - PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES - (GRUPO4) PDF
Quiz 2 - Semana 7 - RA - PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES - (GRUPO4) PDF
Quiz 2 - Semana 7
Instrucciones
https://poli.instructure.com/courses/11282/quizzes/41095 1/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
Historial de intentos
Pregunta 1 0 / 9 ptos.
int m = n * 2;
int i = 1;
while (i < m) {
int j = 1;
while (j < m) {
if (i == 1 || i == m - 1) {
if (j <= n)
System.out.print (" " + j + " ");
else
System.out.print (" " + (m - j) + " ");
} else if (j == 1 || j == m - 1) {
if (i <= n)
System.out.print (" " + i + " ");
else
System.out.print (" " + (m - i) + " ");
} else {
System.out.print (" ");
} j = j + 1;
}
System.out.println ();
i = i + 1;
}
https://poli.instructure.com/courses/11282/quizzes/41095 2/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
1 1
2 2
3 3
4 4
5
4 4
3 3
2 2
1 1
espuesta correcta
1 2 3 4 5 4 3 2 1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1 2 3 4 5 4 3 2 1
Respondido
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
Pregunta 2 9 / 9 ptos.
¡Correcto!
System.out.println(Arrays.toString(arreglo));
System.out.println(Arreglo);
Pregunta 3 9 / 9 ptos.
Se dice que dos números naturales son primos relativos si no tienen ningún factor
primo en común o, dicho de otra manera, si y sólo si su máximo común divisor es
igual a 1. Dados dos números naturales a y b , cuál de los siguientes fragmentos
de código dice correctamente si son o no primos relativos?
¡Correcto!
int c = a;
if (a > b)
c = b;
int i = 2;
boolean resultado = true;
while (resultado && i < c) {
if (a % i == 0 && b % i == 0)
resultado = false;
i = i + 1;
}
int i = 2;
boolean resultado = true;
while (i < a) {
if (a % i != 0 && b % i != 0)
resultado = false;
i = i + 1;
}
https://poli.instructure.com/courses/11282/quizzes/41095 4/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
int c = a;
if (a > b)
c = b;
int i = 2;
boolean resultado;
while (i < c) {
if (a % i == 0 && b % i == 0)
resultado = false;
else
resultado = true;
i = i + 1;
}
int c = a;
if (a > b)
c = b;
int i = 2;
boolean resultado = true;
while (resultado && i < c) {
if (a % i == 0 || b % i == 0)
resultado = false;
i = i + 1;
}
Pregunta 4 9 / 9 ptos.
int m = n * 2;
int i = 1;
while (i < m) {
int j = 1;
while (j < m) {
if (i == j || m - i == j) {
if (i <= n)
System.out.print (" " + i + " ");
else
System.out.print (" " + (m - i) + " ");
} else {
System.out.print (" ");
https://poli.instructure.com/courses/11282/quizzes/41095 5/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
}
j = j + 1;
}
System.out.println ();
i = i + 1;
}
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 5 4 3 2 1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1 2 3 4 5 4 3 2 1
¡Correcto!
1 1
2 2
3 3
4 4
5
4 4
3 3
2 2
1 1
https://poli.instructure.com/courses/11282/quizzes/41095 6/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
Pregunta 5 9 / 9 ptos.
int m = n * 2;
int i = n;
while (i >= 1) {
int j = 1;
while (j < m) {
if (j >= i && j <= m - i) {
if (j <= n)
System.out.print (" " + (j - i + 1) + " ");
else
System.out.print (" " + (m - j - i + 1) + " ");
} else {
System.out.print (" ");
}
j = j + 1;
}
System.out.println ();
i = i - 1;
}
1 1
2 2
3 3
4 4
5
4 4
3 3
2 2
1 1
¡Correcto!
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
https://poli.instructure.com/courses/11282/quizzes/41095 7/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
1 2 3 4 5 4 3 2 1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1 2 3 4 5 4 3 2 1
Pregunta 6 9 / 9 ptos.
boolean a = false;
boolean b = true;
while (true || a == b) {
System.out.println ("...");
a = !a;
b = !b;
}
https://poli.instructure.com/courses/11282/quizzes/41095 8/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
¡Correcto!
El ciclo no terminará nunca. Los cambios que se hacen sobre a y b son
irrelevantes porque nunca afectarán al ciclo. Imprimirá ...
indefinidamente.
Pregunta 7 9 / 9 ptos.
https://poli.instructure.com/courses/11282/quizzes/41095 9/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
int a=2,i,n;
System.out.println("Ingrese numero");
n=sc.nextInt();
for(i=1;i<(n+1);i++){
if(n%i==0){
a++;
}
}
if(a!=3){
System.out.println("No es Primo");
}else{
System.out.println("Si es Primo");
}
https://poli.instructure.com/courses/11282/quizzes/41095 10/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
Pregunta 8 9 / 9 ptos.
import java.util.Math;
import java.util.String;
¡Correcto!
import java.util.Arrays;
import java.util.Scanner;
Pregunta 9 9 / 9 ptos.
¡Correcto!
Cuando el programa se hace largo y complicado
¡Correcto!
Cuando se identifican tareas repetitivas en el código.
Pregunta 10 9 / 9 ptos.
https://poli.instructure.com/courses/11282/quizzes/41095 11/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
int m = n * 2;
int i = 1;
while (i <= n) {
int j = 1;
while (j < m) {
if (j >= i && j <= m - i) {
if (j <= n)
System.out.print (" " + (j - i + 1) + " ");
else
System.out.print (" " + (m - j - i + 1) + " ");
} else {
System.out.print (" ");
}
j = j + 1;
}
System.out.println ();
i = i + 1;
}
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
¡Correcto!
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
1 2 3 4 5 4 3 2 1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1 2 3 4 5 4 3 2 1
https://poli.instructure.com/courses/11282/quizzes/41095 12/13
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO4]
1 1
2 2
3 3
4 4
5
4 4
3 3
2 2
1 1
Calificación de la evaluación: 81 de 90
https://poli.instructure.com/courses/11282/quizzes/41095 13/13