#include <iostream>
#include <time.h>
#include <windows.h>

using namespace std;

int random(int lowest_number, int highest_number)
{
  int range = highest_number - lowest_number + 1;
  return lowest_number + int(range * rand()/(RAND_MAX + 1.0));
}

void randcolor(void)
{
  unsigned int color;
  switch (random(0,1)) {
    case 0: color = 10; break;
    case 1: color = 2;
  }
  HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
  SetConsoleTextAttribute(hcon,(WORD)(color));
}

void gotopos(int xpos, int ypos)
{
  COORD scrn;    
  HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
  scrn.X = xpos; scrn.Y = ypos;
  SetConsoleCursorPosition(hOuput,scrn);
}

void mtrx_col(int x)
{
  unsigned int ended = 0;
  unsigned char chr;
  for (unsigned int i = 1; i <= 25; i++) {
    if (ended != 1) {
      randcolor();
      chr = (char)random(158,254);
      gotopos(x,i);
      cout << chr;
      for (unsigned int j = 0; j <= 500000; j++);
      ended = random(0,10);
    } else {
      gotopos(x,i);
      cout << " ";
    }
  }
}

void clear_col(int x)
{
  for (unsigned int i = 1; i <= 25; i++) {
    gotopos(x,i);
    cout << " ";
  }
}

int main(void)
{
  int x;
  srand(time(NULL));
  while (TRUE) {
    x = random(0,80);
    clear_col(x);
    if (random(0,1) == 1) {
      mtrx_col(x);
    }
  }
  return 0;
}

