Help I need to build a subroutine that allows you to invert the contents of an array of N cells

0

Why is it wrong? help I feel frustrated and stuck because something that seems so simple does not come out. I need advice from you as experienced programmers I feel useless.

SubProceso respuesta <- inversion (N)
    Definir arreglo, i como entero;

    i<-0;
    para i<-0 hasta N con paso -1 Hacer
        arreglo[i]<- Azar(40);
    FinPara
Fin SubProceso

Proceso principal
    Dimension arreglo[N];

    Definir arreglo, N, i como entero;

    i<-0;

    Escribir 'ingresa la cantidad de numeros';
    Leer N;

    para i<-0 hasta N-1 con paso 1 Hacer
        arreglo[i]<-azar(40);
        Escribir arreglo[i];
    FinPara


    Para i<-0 hasta N-1 hacer
        inversion(N);
    FinPara
FinProceso
    
asked by Sebastian Ortiz 03.07.2017 в 01:32
source

2 answers

0

It's the first time I see a language in Spanish hahaha. I do not know it but according to my logic I would do this:

for i

answered by 03.07.2017 в 02:53
0

First , you must configure PSeInt to accept variable capacity arrays Second you have to pass the fix to the SubProcess response (remember that there are no global variables in PseInt) Third , you are applying the random function again to invert the array, when you must reverse the array, not randomly assign numbers Fourth An arrangement, both for reading and writing, is only traversed once. Fifth inversion is a process with no return, it does not return any value, the variable you declared does not make any sense since it never takes any value and therefore will show a zero on the screen.

>
SubProceso inversion (arreglo,N)
    Definir i Como Entero;
    Para i<-N-1 Hasta 0 Con Paso -1  Hacer
        Escribir arreglo[i];
    FinPara
FinSubProceso

Proceso Principal
    Definir arreglo, i, N Como Enteros;

    Escribir "ingresa la cantidad de numeros";
    Leer N;

    Dimension arreglo[N];

    Para i<-0 Hasta N-1 Con Paso 1 Hacer
        arreglo[i]<-azar(40);
        Escribir arreglo[i];
    FinPara

    Escribir "";
    Escribir "Arreglo invertido:";
    Escribir "";

    inversion(arreglo,N);

FinProceso
    
answered by 18.09.2017 в 19:32