Sunteți pe pagina 1din 11

14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

Quiz 2 - Semana 7

Fecha límite 15 de oct en 23:55 Puntos 90 Preguntas 10


Disponible 12 de oct en 0:00-15 de oct en 23:55 4 días Tiempo límite 90 minutos
Intentos permitidos 2

Instrucciones

https://poli.instructure.com/courses/11281/quizzes/41093 1/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

Volver a realizar la evaluación

Historial de intentos

Intento Tiempo Puntaje


ÚLTIMO Intento 1 40 minutos 81 de 90

Calificación para este intento: 81 de 90


Presentado 14 de oct en 23:20
Este intento tuvo una duración de 40 minutos.

Pregunta 1 9 / 9 ptos.

Suponiendo que inicialmente n = 5 , qué imprime el siguiente


fragmento de código?

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

https://poli.instructure.com/courses/11281/quizzes/41093 2/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

1 1
2 2
3 3
4 4
5
4 4
3 3
2 2
1 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

Pregunta 2 9 / 9 ptos.

Suponiendo que inicialmente n = 5 , qué imprime el siguiente


fragmento de código?

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 {

https://poli.instructure.com/courses/11281/quizzes/41093 3/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

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

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 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
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1

Pregunta 3 9 / 9 ptos.

https://poli.instructure.com/courses/11281/quizzes/41093 4/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

Para llenar un arreglo desde la primera posición del mismo, Cuál seria
la manera correcta de realizar nuestro ciclo for ?

for (int i=3;i<final;i++){

for (int i=1;i<final;i++){

¡Correcto!
for (int i=0;i<final;i++){

for (int i=2;i<final;i++){

Pregunta 4 9 / 9 ptos.

¿Cuál de los siguientes fragmentos de código determina


correctamente si el valor n, ingresado por el usuario, es o no primo?

Scanner sc = new Scanner(System.in);


int a=3,i,n;
System.out.println("Ingrese numero");
n=sc.nextInt();
for(i=1;i<(n+1);i++){
if(n%i==0){
a++;
}
}
if(a!=5){
System.out.println("No es Primo");
}else{
System.out.println("Si es Primo");
}

https://poli.instructure.com/courses/11281/quizzes/41093 5/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

Scanner sc = new Scanner(System.in);


int a=0,i,n;
System.out.println("Ingrese numero");
n=sc.nextInt();
for(i=1;i<(n+1);i++){
if(n%i==4){
a++;
}
}
if(a!=3){
System.out.println("No es Primo");
}else{
System.out.println("Si es Primo");
}

¡Correcto! Scanner sc = new Scanner(System.in);


int a=0,i,n;
System.out.println("Ingrese numero");
n=sc.nextInt();
for(i=1;i<(n+1);i++){
if(n%i==0){
a++;
}
}
if(a!=2){
System.out.println("No es Primo");
}else{
System.out.println("Si es Primo");
}

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/11281/quizzes/41093 6/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

Pregunta 5 9 / 9 ptos.

Según la teoría del curso, la definición e implementación de métodos


permite organizar mejor el trabajo y descomponer la lógica de los
algoritmos que escribimos.

¡Correcto!
True

False

Pregunta 6 0 / 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?

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;
}

https://poli.instructure.com/courses/11281/quizzes/41093 7/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

Respondido
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;
}

espuesta correcta
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;
}

Pregunta 7 9 / 9 ptos.

Cuál es la librería que debo llamar para imprimir un arreglo en pantalla


?

import java.util.String;

https://poli.instructure.com/courses/11281/quizzes/41093 8/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

import java.util.Scanner;

import java.util.Math;

¡Correcto!
import java.util.Arrays;

Pregunta 8 9 / 9 ptos.

Considere el siguiente fragmento de código. Seleccione la opción


donde todas las afirmaciones sean correctas.

boolean a = false;
boolean b = true;
while (true || a == b) {
System.out.println ("...");
a = !a;
b = !b;
}

¡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.

El ciclo se ejecutará exactamente una vez, porque al cambiar los


valores de a y b se detendrá.

El ciclo nunca se ejecutará.

El ciclo terminará dependiendo de los valores de a y b . El valor true


en la condición del ciclo no afecta al ciclo. Imprimirá ... cuando a
sea igual a b .

El ciclo terminará dependiendo de los valores de a y b . El valor true


en la condición del ciclo afecta al ciclo dependiendo de los valores de
a y b .

https://poli.instructure.com/courses/11281/quizzes/41093 9/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

Pregunta 9 9 / 9 ptos.

Suponiendo que inicialmente n = 5 , Cuál es la impresión resultante del


siguiente fragmento de código?

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 (" ");
}
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

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

https://poli.instructure.com/courses/11281/quizzes/41093 10/11
14/10/2019 Quiz 2 - Semana 7: RA/PRIMER BLOQUE-PROGRAMACION DE COMPUTADORES-[GRUPO3]

¡Correcto!
1 1
2 2
3 3
4 4
5
4 4
3 3
2 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 10 9 / 9 ptos.

La recursión se basa en la definición de la solución de problemas con


base en llamadas a un mismo método, desde sí mismo.

¡Correcto!
True

False

Calificación de la evaluación: 81 de 90

https://poli.instructure.com/courses/11281/quizzes/41093 11/11

S-ar putea să vă placă și