Coder Social home page Coder Social logo

buffer-circular's Introduction

Documentación para el código

El siguiente código en Python crea una matriz de tamaño tam y permite al usuario ingresar datos en ella hasta que se ingrese la palabra "fin".

tam = 5  # Define el tamaño de la matriz
~~t = tam - 1  # Variable auxiliar~~
matriz = [None] * tam  # Crea una matriz de tamaño 'tam' con todos los elementos inicializados en None
i = 0  # Índice para recorrer la matriz

# Bucle que se ejecuta hasta que se llena la matriz
while i < tam:
    print(matriz)  # Imprime el estado actual de la matriz
    dto = input("Ingrese un dato: ")  # Solicita al usuario un dato para agregar a la matriz
    if dto == "fin":  # Si el usuario ingresa 'fin', se termina el bucle
        break
    print(f"i: {i}")  # Imprime el índice actual
    if matriz[i] != 0:  # Si el elemento en el índice actual de la matriz no es 0, se agrega el dato ingresado por el usuario
        print(f"Se agrego el dato {dto} en la posicion {i} con el valor {matriz[i]}")  # Imprime un mensaje indicando que se agregó el dato
        matriz[i] = dto  # Agrega el dato en el índice actual de la matriz
        i += 1  # Incrementa el índice
        if i == tam:  # Si el índice es igual al tamaño de la matriz, se reinicia a 0
            i = 0

buffer-circular's People

Contributors

unaiccz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.