lunes, 23 de abril de 2012

Matrix en C++

Aquí tenéis el código:

#include "stdafx.h"
#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <ctime>
using namespace std;



int main(int argc, char* argv[])
{
    int a;
    srand(time(NULL));    
    // Inicialización de la tabla de caracteres seleccionables.
    char arr[64]={'A','0','B','C','3','D','E','7','F','G','H',' ','I','J','5','K',
                  '6','L','M','N','O','P','Q','!','R','S','T','U','V','W','X','Y',
                  ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','Z','1','2','4','6','8',
                  '9',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', '};
    system("color 0A"); // Consola en verde.
    while (1)
    {
          Sleep(50);
          char pline[40];
          for(int i=0; i<39; i++)
          {
             a=rand()%64; // Selecciona un char aleatorio
             if (pline[i] != ' ') {   
                cout<<arr[a]<<" "; // Se imprime
             } else {
                cout<<" "<<" ";
             }
             pline[i] = arr[a];
          }
          cout<<endl;
    }
    system("pause");
    return 0;
}


Y aquí el resultado:




No hay comentarios:

Publicar un comentario