954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

The Matrix: Char Reloaded

Here's a funny program that simulates the matrix...waaay off topic...

#include <iostream>
#include <ctime>

using namespace std;

const int NotUsed=system("color 02");

int main()
{
    clock();
    int n;
    double time;
    char matrixwords[]="  aijk FGHIJKlmnopqrs  ABCDtuvELMNO  PQRS bcde fghTUVWXYwxyzZ";
    char matrix[]="01001100100101011110";
    
    clock();
    for(int o=1; o<=70; o++)
    {
            cout << "/";
            }
            cout << "\n\n\t\t\tThe Matrix\n\n";
    for(int o=1; o<=70; o++)
    {
            cout << "/";
            }
            cout << "\n\n\tEnter Matrix ID: (KB's of Data) ::==:: ";
            cin >> n;
            for(double t=-1000; t<=1000000; t++);
            cout << "\n\n\tLoading Matrix Engine.";
            for(double t=0; t<=5; t++)
            {
                       for(double u=-10000; u<=10000000; u++);
                       cout << " . ";
                       }
                       time=clock()/1000.0;
                       cout << "\n\n\t\tYou waited " << time << " seconds for the matrix to generate\n\n\t";
    
    for(int i=1; i<=n; i++)
    {
            for(int j=1; j<=60; j++)
            {
                    if((j%2==0) || (j%5==0) || (j%13==0))
                    {
                              int ran( rand()%21 );
                              cout << matrix[ran];
                              }
                              else if(j%3==0)
                              {
                                   int ran( rand()%66 );
                                  cout << matrixwords[ran];
                                  }
                                  else if(j%7==0)
                                  {
                                       int ran( rand()%66 );
                                       cout << matrixwords[ran];
                                       }
                                  else
                                  {
                                      int ran( rand()%66 );
                                      cout << matrixwords[ran];
                                      }
                    }
                    cout << "\n\t";
            }
            time+=clock()/1000.0;
    
    cout << "\n\n\tTotal Time Taken for the Matrix to Run: " << time << " s\n\n\t";
    cin.get();
    return 0;
}


programmed in c++.. kinda dumb..but still

amrith92
Junior Poster
188 posts since Jul 2008
Reputation Points: 130
Solved Threads: 23
 

Yes, it's a severe blow for all C++-lovers...
And your question is...

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 

Compiled id, kindda funny ya, though...
Not really usefull to be honest :P

Tigran
Junior Poster in Training
92 posts since Jun 2008
Reputation Points: 24
Solved Threads: 8
 
Yes, it's a severe blow for all C++-lovers... And your question is...

No question...I just thought it was kinda funny...it was in another forum, but got moved here...Compiled id, kindda funny ya, though...
Not really usefull to be honest :P

Yeah...there is no point in the code...it just simulates the matrix

amrith92
Junior Poster
188 posts since Jul 2008
Reputation Points: 130
Solved Threads: 23
 

Well, in that case a free advice for a C++ coder: look at the C++ language definition. Must be int main() , not improbable void main() in signature ;)...

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 

Whatever it is, it looks pretty lame and probably could be improved with a clearscreen function that is system dependent.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 
Well, in that case a free advice for a C++ coder: look at the C++ language definition. Must be int main() , not improbable void main() in signature ;)...

Yeah...I know about that but int main() would need a return statement, which would make my signature 6 lines, one more than is allowed... and anyway, its only just a signature!

amrith92
Junior Poster
188 posts since Jul 2008
Reputation Points: 130
Solved Threads: 23
 

Reminds me of the grandaddy of all screensavers. Something like

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main()
  {
  srand( time( NULL ) );
  while (1) printf( "%*c", rand() % 15, '*' );
  return 0;
  }

(This, of course, is just the simplest possible version...)

Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
 

Thank you, Duodas, for this brilliant code!
It's so pity it's not a part of the C RTL...

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 

You gotta admit, the Classics are good!

amrith92
Junior Poster
188 posts since Jul 2008
Reputation Points: 130
Solved Threads: 23
 
Yeah...I know about that but int main() would need a return statement, which would make my signature 6 lines, one more than is allowed... and anyway, its only just a signature!


Good news for amrith92: The C++ Standard does not require explicit return statement in int main() !

ArkM
Postaholic
2,001 posts since Jul 2008
Reputation Points: 1,234
Solved Threads: 348
 
Good news for amrith92: The C++ Standard does not require explicit return statement in int main() !

Hear, Hear! So this means my Signature is valid!! Anyways, it isn't a standard and I would urge myself never to comment on it again!

amrith92
Junior Poster
188 posts since Jul 2008
Reputation Points: 130
Solved Threads: 23
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You