Matrix Effect In C/C++

matrix
First open your c++ IDE. after that create a new project and put these codes inside.
#include 
#include 
#include 
#include 
using namespace MatrixC;

int main()
{
   system("color 0a");
   srand(time(0));
   char random_char = ((rand() % 127));
   bool going = true, checking = true;

   while (going = true)
   {
   
      for (int x = 0; x < 38; x++)
      {
                  random_char = ((rand() % 127) + 50);
         checking = true;
         while (checking)
         {
            if  ( 
               
                  (random_char == 32) || (random_char == 39) || (random_char == 46) ||
                  (random_char == 44) || (random_char == 34) || (random_char == 45) ||
                  (random_char == 58) || (random_char == 59) || (random_char == 94) ||
                  (random_char == 95) || (random_char == 96) || (random_char == 126)
               
                )
            random_char = ((rand() % 127) + 50);
                                 else break;
         }
                 cout << random_char << " ";
      }
          cout << endl;
        
         Sleep(20);
   }
   cin.get();
   return 0;
}
The includes are the namespaces in c++ , the code system("color 0a"); is the green color text of our Matrix effect (color oa is the system name for green) ,  srand(time(0)); is the random speed , for (int x = 0; x < 38; x++) draws the rows of characters , random_char = ((rand() % 127) + 50); checking = true; while (checking) generates the first character ,

 this (random_char == 32) || (random_char == 39) || (random_char == 46) || (random_char == 44) || (random_char == 34) || (random_char == 45) || (random_char == 58) || (random_char == 59) || (random_char == 94) || (random_char == 95) || (random_char == 96) || (random_char == 126) checks for bad characters ,

this random_char = ((rand() % 127) + 50); generates random characters if bad characters generated , this else break; will continue to print if good characters generated , this cout << random_char << " "; prints character , this  cout << endl; if full characters were printed will continue to next row , this delays Sleep(20); .

You can see a preview of the matrix on top of this post.

How To : Matrix on C# Console

hello all , after a long time i am back to write , so today i am gonna teach you to create a matrix screen on c# console , its pretty easy so lets begin making it , open your visual c# 2008/2010 and select console application and name it whatever you want now add this code


#define readkey
using System;

namespace m7tr1x
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "Matrix";
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WindowLeft = Console.WindowTop = 0;
            Console.WindowHeight = Console.BufferHeight = Console.LargestWindowHeight;
            Console.WindowWidth = Console.BufferWidth = Console.LargestWindowWidth;
#if readkey
            Console.WriteLine("Press Any Key to Continue");
            Console.ReadKey();
#endif
            Console.CursorVisible = false;
            int width, height;
            int[] y;
            int[] l;
            Initialize(out width, out height, out y, out l);
            int ms;
            while (true)
            {
                DateTime t1 = DateTime.Now;
                MatrixStep(width, height, y, l);
                ms = 10 - (int)((TimeSpan)(DateTime.Now - t1)).TotalMilliseconds;
                if (ms > 0)
                    System.Threading.Thread.Sleep(ms);
                if (Console.KeyAvailable)
                    if (Console.ReadKey().Key == ConsoleKey.F5)
                        Initialize(out width, out height, out y, out l);
            }
        }

        static bool thistime = false;

        private static void MatrixStep(int width, int height, int[] y, int[] l)
        {
            int x;
            thistime = !thistime;
            for (x = 0; x < width; ++x)
            {
                if (x % 11 == 10)
                {
                    if (!thistime)
                        continue;
                    Console.ForegroundColor = ConsoleColor.White;
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.DarkGreen;
                    Console.SetCursorPosition(x, inBoxY(y[x] - 2 - (l[x] / 40 * 2), height));
                    Console.Write(R);
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                Console.SetCursorPosition(x, y[x]);
                Console.Write(R);
                y[x] = inBoxY(y[x] + 1, height);
                Console.SetCursorPosition(x, inBoxY(y[x] - l[x], height));
                Console.Write(' ');
            }
        }

        private static void Initialize(out int width, out int height, out int[] y, out int[] l)
        {
            int h1;
            int h2 = (h1 = (height = Console.WindowHeight) / 2) / 2;
            width = Console.WindowWidth - 1;
            y = new int[width];
            l = new int[width];
            int x;
            Console.Clear();
            for (x = 0; x < width; ++x)
            {
                y[x] = r.Next(height);
                l[x] = r.Next(h2 * ((x % 11 != 10) ? 2 : 1), h1 * ((x % 11 != 10) ? 2 : 1));
            }
        }

        static Random r = new Random();
        static char R
        {
            get
            {
                int t = r.Next(10);
                if (t <= 2)
                    return (char)('0' + r.Next(10));
                else if (t <= 4)
                    return (char)('a' + r.Next(27));
                else if (t <= 6)
                    return (char)('A' + r.Next(27));
                else
                    return (char)(r.Next(32, 255));
            }
        }

        public static int inBoxY(int n, int height)
        {
            n = n % height;
            if (n < 0)
                return n + height;
            else
                return n;
        }
    }
}


now run the application , enjoy