ALGORITMO QUE REGISTRE 3 USUARIOS EN UNA MATRIZ

Matriz - Matrices - Vector Bidimensional


Algoritmo que ingrese datos en una matriz

Registrar código, nombre, apellido en una matriz en PSeInt.

💻 Crear una matriz de 3 x 4, luego solicite por teclado el código, nombre, apellido y dirección de 3 alumnos y los visualice cargados en una matriz de la siguiente manera: Ejemplo.

registra datos del cliente en una matriz

Algoritmo en pseint que registre 3 datos en una matriz PSeInt Estricto :

Algoritmo programacion_work
    Definir datos como Caracter;
    Definir f, c como Entero;
    Dimension datos[3,4];
    //Lee Datos CODIGO, NOMBRE, APELLIDO, DIRECCIÓN
    Para f <- 0 hasta 2 con paso 1 hacer      
        Escribir Sin Saltar "CODIGO    : ";
        Leer datos[f,0];
        Escribir Sin Saltar "NOMBRE    : ";
        Leer datos[f,1];
        Escribir Sin Saltar "APELLIDO  : ";
        Leer datos[f,2];
        Escribir Sin Saltar "DIRECCIÓN : ";
        Leer datos[f,3];
        Escribir "";
    FinPara
    //Mostrar Datos
    Escribir "CODIGO   NOMBRE   APELLIDO   DIRECCIÓN";
    Para f <- 0 hasta 2 con paso 1 hacer
        Para c <- 0 hasta 3 con paso 1 hacer      
            Escribir Sin Saltar datos[f,c],"     ";
        FinPara   
        Escribir "";
    FinPara  
FinAlgoritmo

código en python para registrar 3 clientes en una matriz Python :

datos = [[str() for ind0 in range(4)] for ind1 in range(3)]
# Lee Datos CODIGO, NOMBRE, APELLIDO, DIRECCIÓN
for f in range(3):
    datos[f][0] = input("CODIGO    : ")
    datos[f][1] = input("NOMBRE    : ")
    datos[f][2] = input("APELLIDO  : ")
    datos[f][3] = input("DIRECCIÓN : ")
    print("")
# Mostrar Datos
print("CODIGO  NOMBRE  APELLIDO  DIRECCIÓN")
for f in range(3):
    for c in range(4):
        print(datos[f][c],end="   ")
    print()

código en Lenguaje C que registre 3 clientes Lenguaje C :

#include<stdio.h>
#define MAX_STRLEN 256
int main() {
    char datos[MAX_STRLEN][3][4];
    /* Lee Datos CODIGO, NOMBRE, APELLIDO, DIRECCIÓN */
    for (int f=0;f<=2;f++) {
        printf("CODIGO    : ");       
        gets(datos[f][0]);		
        printf("NOMBRE    : ");        
        gets(datos[f][1]);        
        printf("APELLIDO  : ");
        gets(datos[f][2]);        
        printf("DIRECCION : ");
        gets(datos[f][3]);        
        printf("\n");
    }
    /* Mostrar Datos */
    printf("\nCODIGO   NOMBRE  APELLIDO  DIRECCION\n");
    for (int f=0;f<=2;f++){
        for (int c=0;c<=3;c++){
            printf("%s    ",datos[f][c]);
        }		
        printf("\n");
    }
    return 0;
}

código en Dev C++ para registrar 3 datos en una matriz de 3 x 4 Dev C++ :

#include<iostream>
using namespace std;
int main() {    
    string datos[3][4];
    // Lee Datos CODIGO, NOMBRE, APELLIDO, DIRECCIÓN
    for (int f=0;f<=2;f++) {
        cout << "CODIGO    : ";
        cin >> datos[f][0];
        cout << "NOMBRE    : ";
        cin >> datos[f][1];
        cout << "APELLIDO  : ";
        cin >> datos[f][2];
        cout << "DIRECCION : ";
        cin >> datos[f][3];
        cout << endl;
    }
    // Mostrar Datos
    cout << "CODIGO   NOMBRE  APELLIDO  DIRECCION" << endl;
    for (int f=0;f<=2;f++) {
        for (int c=0;c<=3;c++) {
            cout << datos[f][c] << "    ";
        }		
        cout << endl;
    }
    return 0;
}



Facebook de www.programacion.work. Canal de Youtube de www.programacion.work. Twitter de www.programacion.work. TikTok de www.programacion.work.


Política de cookies

Política de Privacidad

Aviso Legal y Términos De Uso