943,918 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2015
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 6th, 2008
0

The Matrix: Char Reloaded

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

C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5.  
  6. const int NotUsed=system("color 02");
  7.  
  8. int main()
  9. {
  10. clock();
  11. int n;
  12. double time;
  13. char matrixwords[]=" aijk FGHIJKlmnopqrs ABCDtuvELMNO PQRS bcde fghTUVWXYwxyzZ";
  14. char matrix[]="01001100100101011110";
  15.  
  16. clock();
  17. for(int o=1; o<=70; o++)
  18. {
  19. cout << "/";
  20. }
  21. cout << "\n\n\t\t\tThe Matrix\n\n";
  22. for(int o=1; o<=70; o++)
  23. {
  24. cout << "/";
  25. }
  26. cout << "\n\n\tEnter Matrix ID: (KB's of Data) ::==:: ";
  27. cin >> n;
  28. for(double t=-1000; t<=1000000; t++);
  29. cout << "\n\n\tLoading Matrix Engine.";
  30. for(double t=0; t<=5; t++)
  31. {
  32. for(double u=-10000; u<=10000000; u++);
  33. cout << " . ";
  34. }
  35. time=clock()/1000.0;
  36. cout << "\n\n\t\tYou waited " << time << " seconds for the matrix to generate\n\n\t";
  37.  
  38. for(int i=1; i<=n; i++)
  39. {
  40. for(int j=1; j<=60; j++)
  41. {
  42. if((j%2==0) || (j%5==0) || (j%13==0))
  43. {
  44. int ran( rand()%21 );
  45. cout << matrix[ran];
  46. }
  47. else if(j%3==0)
  48. {
  49. int ran( rand()%66 );
  50. cout << matrixwords[ran];
  51. }
  52. else if(j%7==0)
  53. {
  54. int ran( rand()%66 );
  55. cout << matrixwords[ran];
  56. }
  57. else
  58. {
  59. int ran( rand()%66 );
  60. cout << matrixwords[ran];
  61. }
  62. }
  63. cout << "\n\t";
  64. }
  65. time+=clock()/1000.0;
  66.  
  67. cout << "\n\n\tTotal Time Taken for the Matrix to Run: " << time << " s\n\n\t";
  68. cin.get();
  69. return 0;
  70. }

programmed in c++.. kinda dumb..but still
Reputation Points: 130
Solved Threads: 22
Junior Poster
amrith92 is offline Offline
187 posts
since Jul 2008
Sep 6th, 2008
0

Re: The Matrix: Char Reloaded

Yes, it's a severe blow for all C++-lovers...
And your question is...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Sep 7th, 2008
0

Re: The Matrix: Char Reloaded

Compiled id, kindda funny ya, though...
Not really usefull to be honest
Reputation Points: 24
Solved Threads: 8
Junior Poster in Training
Tigran is offline Offline
90 posts
since Jun 2008
Sep 7th, 2008
-1

Re: The Matrix: Char Reloaded

Click to Expand / Collapse  Quote originally posted by ArkM ...
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...

Click to Expand / Collapse  Quote originally posted by Tigran ...
Compiled id, kindda funny ya, though...
Not really usefull to be honest
Yeah...there is no point in the code...it just simulates the matrix
Last edited by amrith92; Sep 7th, 2008 at 8:44 am.
Reputation Points: 130
Solved Threads: 22
Junior Poster
amrith92 is offline Offline
187 posts
since Jul 2008
Sep 7th, 2008
0

Re: The Matrix: Char Reloaded

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 ...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Sep 7th, 2008
0

Re: The Matrix: Char Reloaded

Whatever it is, it looks pretty lame and probably could be improved with a clearscreen function that is system dependent.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Sep 7th, 2008
0

Re: The Matrix: Char Reloaded

Click to Expand / Collapse  Quote originally posted by ArkM ...
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!
Last edited by amrith92; Sep 7th, 2008 at 2:05 pm.
Reputation Points: 130
Solved Threads: 22
Junior Poster
amrith92 is offline Offline
187 posts
since Jul 2008
Sep 7th, 2008
0

Re: The Matrix: Char Reloaded

Reminds me of the grandaddy of all screensavers. Something like
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4.  
  5. int main()
  6. {
  7. srand( time( NULL ) );
  8. while (1) printf( "%*c", rand() % 15, '*' );
  9. return 0;
  10. }
(This, of course, is just the simplest possible version...)
Featured Poster
Reputation Points: 1140
Solved Threads: 229
Postaholic
Duoas is offline Offline
2,039 posts
since Oct 2007
Sep 7th, 2008
0

Re: The Matrix: Char Reloaded

Thank you, Duodas, for this brilliant code!
It's so pity it's not a part of the C RTL...
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Sep 7th, 2008
0

Re: The Matrix: Char Reloaded

You gotta admit, the Classics are good!
Reputation Points: 130
Solved Threads: 22
Junior Poster
amrith92 is offline Offline
187 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Connecting a MIDI-device and getting input signal from it?
Next Thread in C++ Forum Timeline: Resource File Error





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC