miércoles, 7 de septiembre de 2011

Introducción al uso de tablas en lenguaje C/C++.


Introducción al uso de tablas en lenguaje C/C++.

Introducir desde teclado diez enteros en una tabla, y mostrarlos en orden inverso.

Enlace CodePad
http://codepad.org/8l4S7yxC

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Código Fuente
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


#include <iostream>

using namespace std;

int main()
{
    int tabla_enteros [10]={1,2,3,4,5,6,7,8,9,0};

    //se leen los datos y se guardan en orden ascendente.
    for (int i = 0; i < 10; i++)
    {
        cout << "Introduce un numero: ";
        cin >> tabla_enteros [i];
        //cout << endl;
    }

    cout << endl;

    //se muestran los datos en orden descendente
    for (int i = 9; i >=0; i--)
    {
        cout << tabla_enteros [i] << " ";
    }

    return 0;
}

No hay comentarios:

Publicar un comentario

Related Posts Plugin for WordPress, Blogger...