Construct an algorithm that allows to enter a group of people in a matrix by means of subprocesses

0

Construct an algorithm that allows entering a group of people, nombre , run and sexo in a matrix by means of sub processes

Proceso Principal

    Dimension personas[100,3];
    definir nombre, run, sexo Como Caracter;
    definir continuar Como Logico;
    definir respuesta Como Caracter;
    definir cuentapersonas como entero;
    continuar = verdadero;

    Mientras continuar=verdadero hacer
        Escribir "Ingrese el Run : ";
        leer run;
        //validar run o rechazar; primera subrutina

        Escribir "Ingrese Nombre: ";
        leer nombre;

        Escribir "Ingrese sexo : [F/M]"
        //validar solo F o M

        // buscar que no esté repetido; segunda subrutina
        Escribir "Continua? [S/N]";
        //validar s y n.
        si respuesta= "S" y cuentapersonas<=100 Entonces
            continuar = verdadero;
        sino 
            continuar = falso;
        FinSi
    FinMientras

    //mostrar el resultado. tercera subrutina.

FinProceso
    
asked by Sebastian Ortiz 02.07.2017 в 06:36
source

1 answer

1

Functions / Subprocesses

Funcion variable_de_retorno <- nombre_de_la_funcion ( argumento_1, argumento_2, ... )
    // codigo..
FinFuncion

Start with keyword Funcion (alternatively you can use SubProceso or SubAlgoritmo , they are synonymous) followed by the return variable, the assignment sign, the name of the subprocess, and finally, the list of arguments in brackets. There are variants for this structure.

  • If the function does not return any value, the variable of return and the assignment sign. That is, it can be placed directly the name and the arguments after the word Key Function.

  • If the thread does not receive no value, the empty parenthesis or omit, ending the first line with the name of the subprocess.

In addition, the keywords Por Valor or Por Referencia may optionally be added to indicate the type of passage in each argument. If not indicated, the arrays are passed by reference, the other expressions by value.

  • The passage by reference implies that if the function modifies the argument, the variable that was used in the call.

  • The Value Pass implies that the function operates with a copy of the variable (or the result of the expression) that was used in the call, so that the modifications applied by the function are not will be reflected outside of it.

To invoke the function you must use its name and in parentheses the parameters.

// Funcion que no recibe argumentos ni devuelve nada
Funcion Saludar
    Escribir "Hola mundo!"
FinFuncion

// Funcion que recibe el argumento nombre, y devuelve el saludo
Funcion respuesta <- SaludarA(nombre) 
    respuesta <- "Hola " + nombre
FinFuncion

// Proceso principal, que invoca a las funciones antes declaradas
Algoritmo PruebaFunciones

    // Llamada a la funcion Saludar
    // Como no recibe argumentos pueden omitirse los paréntesis vacios
    Saludar

    // Llamada a la función SaludarA()
    Escribir "Ingrese el nombre de la persona:"
    Leer nombrePersona
    Escribir SaludarA(nombre)

FinAlgoritmo
  

The documentation on the pseudocode is found in the option Ayuda > Indice of the navigation bar or by the keyboard shortcut F1 .

    
answered by 02.07.2017 в 07:43