Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
si se lee N=7 , se imprimirá 0,1,2,3,4,5,6,7
Alguien que me pueda ayudar con este ejercicio por favor, es en Java :c . Hacer un programa que lea un numero N y que imprima todos los número desde 0 a hasta N. Ejemplo: si se lee N=7 , se imprimirá 0,1,2,3,4,5,6,7 NOTA: no se pueden usar ciclos.
3 ответов
+ 3
Write input statement in for loop for multiple input or create one array which size will be 7 like this
int array[7] and use for loop and write input statement inside loop
Read here how to take input
https://www.javatpoint.com/java-program-to-read-number-from-standard-input
+ 2
NOTA: No se pueden utilizar ciclos. ¿Aquí ciclos significa? Bucles? ¿Está permitida la recursividad? Si es así, utilice la variable estática para N. Lleve la entrada a N. Llame a una función que imprima M (de 0 a N) llame de forma recursiva con M + 1 hasta M == N o Hasta M <= N ..
(translated this)
NOTE: Cycles cannot be used.
Here cycles means? Loops? Is recursion is allowed?
If yes, then use static variable for N. Take input to N. Call a function which prints M (from 0 to N) recursively call with M+1 until M==N or Until M<=N..
Edit :
Ex :
Ana Patricia Quiñonez Arreola
print(M); //calling method
static void print(int M) {
System.out.println(M);
if(M<=N)
print(M+1); //recursively calling this method...
}
0
Muchas gracias 😌, si está permitida la recursividad, gracias!!