Skip to content

Instantly share code, notes, and snippets.

@guilleiguaran
Created August 26, 2010 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilleiguaran/550803 to your computer and use it in GitHub Desktop.
Save guilleiguaran/550803 to your computer and use it in GitHub Desktop.
#include <conio.h>
#include "StdAfx.h"
#include "gotoxy.h"
#include "colores.h"
using namespace std;
//---------------------------------------------------------------------------
enum Options {intro = 1, see, add, mult, search, sum};
int Mx0[7][7], Mx1[7][7], Mx2[7][7], Mx3[7][7], Mx4[7][7], Mx5[7][7], Mx[7][7], Mxx[7][7];
int l[6] = {1, 1, 1, 1, 1, 1};
int h[6] = {1, 1, 1, 1, 1, 1};
//---------------------------------------------------------------------------
char IpD[21][28] = {
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'l','l','l','0','0','0','0','0','m','m','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','l','0','0','0','0','0','0','m','0','m','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','l','0','0','0','0','0','0','m','0','m','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','l','0','0','0','k','0','0','m','0','m','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','l','0','0','k','k','k','0','m','0','m','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'l','l','l','0','0','k','0','0','m','m','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','n','n','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','n','0','0','0'},
{'0','n','0','n','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','n','0','0','0'},
{'0','n','0','n','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','n','0','0','0'},
{'0','n','0','n','0','n','0','0','0','n','0','0','n','0','n','0','0','n','0','0','0','n','n','0','n','n','0','0'},
{'0','n','n','0','0','n','n','0','n','0','n','0','n','0','n','0','n','0','n','0','n','0','0','0','n','0','0','0'},
{'0','n','0','0','0','n','0','0','n','0','n','0','n','0','n','0','n','n','n','0','n','0','0','0','n','0','0','0'},
{'0','n','0','0','0','n','0','0','n','0','n','0','n','0','n','0','n','0','0','0','n','0','0','0','n','0','0','0'},
{'0','n','0','0','0','n','0','0','0','n','0','0','0','n','n','0','0','n','n','0','0','n','n','0','0','n','n','0'},
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','n','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','n','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','0','0','0','0','0','0','0','0','0','0','0','n','n','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
{'0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'},
};
//---------------------------------------------------------------------------
void box(int x, int y, int width, int height)
{
for (int j = 1; j <= height; j++)
for (int i = 1; i <= width; i++)
{
gotoxy(x + i, y + j);
printf("%c", 178);
}
}
//---------------------------------------------------------------------------
void Put_IpD(int x, int y, int s)
{
for (int j = 0; j <= 20; j++)
for (int i = 0; i <= 27; i++)
{
color(0, 0);
if (IpD[j][i] != '0')
box(x + (i - 1) * s, y + j + 1, s, 1);
}
for (int j = 0; j <= 20; j++)
for (int i = 0; i <= 27; i++)
{
color(7, int(IpD[j][i]));
if (IpD[j][i] != '0')
box(x + (i - 1) * s + 1, y + j, s, 1);
}
}
//---------------------------------------------------------------------------
void new_page(int x, int y)
{
color(0, 8);
box(x - 1, y + 1, 1, 15);
box(x - 1, y + 15, 40, 1);
color(7, 15);
box(x, y, 40, 15);
}
//---------------------------------------------------------------------------
void title(int x, int y, char *Title)
{
color(1, 15);
gotoxy(x + 1, y + 1);
printf("%s", Title);
gotoxy(x + 1, y + 2);
for (int j = 1; j <= 40; j++)
printf("%c", 178);
}
//---------------------------------------------------------------------------
int menu(int x, int y)
{
int opt = 1, up = 0;
char *shown_option[7] = {" Menu Principal ",
" Nueva Matriz ",
" Ver Matriz ",
" Sumar Matrices ",
" Multiplicar Matrices ",
" Elemento Mayor ",
" Suma De Elementos ",
};
bool chosen = false;
int key;
new_page(x, y);
color(7, 1);
box(x + 1, y + 2, 1, 12);
title(x, y, shown_option[0]);
do
{
color(1, 1);
for (int i = 1; i <= 4; i++)
{
if (opt == i + up)
{
color(7, 8);
gotoxy(x + 5, y + (i - 1) * 3 + 5);
for (int j = 1; j <= 22; j++)
printf("%c", 178);
gotoxy(x + 6, y + (i - 1) * 3 + 4);
color(1, 15);
}
else
{
color(1, 7);
gotoxy(x + 5, y + (i - 1) * 3 + 4);
}
printf("%s", shown_option[i + up]);
}
color(2, 9);
gotoxy(x + 2, y + 2 + opt * 2);
printf("%c", 178);
gotoxy(x + 2, y + 1 + opt * 2);
printf("%c", 178);
key = getchar();
color(7, 1);
box(x + 1, y + 2, 1, 12);
color(7, 15);
for (int i = 1; i <= 4; i++)
{
gotoxy(x + 5, y + (i - 1) * 3 + 4);
for (int j = 1; j <= 22; j++)
printf("%c", 178);
gotoxy(x + 5, y + (i - 1) * 3 + 5);
for (int j = 1; j <= 22; j++)
printf("%c", 178);
}
switch (key)
{
case 72:
if (opt > 1)
--opt;
if (opt <= up)
--up;
break;
case 80:
if (opt < 4)
++opt;
else
{
if (opt < 6)
{
if (up < 2)
++up;
++opt;
}
}
break;
case 13:
chosen = true;
break;
case 27:
color(0, 8);
box(x - 1, y + 1, 40, 15);
color(7, 15);
box(x, y, 40, 15);
return -1;
default:;
}
}
while (!chosen);
new_page(x , y);
return opt;
}
//---------------------------------------------------------------------------
void background(int color1, int color2)
{
color(color2, color1);
box(0, 0, 80, 26);
gotoxy(0, 26);
color(color2, 9);
printf("%s", " ");
new_page(30, 2);
Sleep(200);
new_page(28, 3);
Sleep(300);
new_page(26, 4);
Sleep(400);
Put_IpD(2, 3, 2);
Sleep(500);
gotoxy(28, 7);
color(color2, 15);
printf("%s", " presione cualquier tecla para comenzar");
getchar();
system("cls");
color(color2, color1);
box(0, 0, 80, 26);
gotoxy(0, 26);
color(color2, 4);
printf("%s", " Esc:");
color(color2, 0);
printf("%s", " Salir | ");
color(color2, 4);
printf("%s", " Entrar:");
color(color2, 0);
printf("%s", " Seleccionar | ");
color(color2, 4);
printf("%c", 17);printf("%c", ' ');printf("%c", 16);printf("%c", ' ');
printf("%c", 30);printf("%c", ' ');printf("%c", 31);printf("%c", ':');
color(color2, 0);
printf("%s", " Mover");
Put_IpD(50, 2, 1);
}
//---------------------------------------------------------------------------
void make_operation(int opt)
{
switch (opt)
{
case intro:
break;
case see:
break;
case add:
break;
case mult:
break;
case search:
break;
case sum:
break;
default:;
}
}
//---------------------------------------------------------------------------
int main()
{
int option = 1;
bool ext = false;
background(8, 7);
do
{
option = menu(5, 5);
if (option == -1)
ext = true;
else
make_operation(option);
}
while (!ext);
return 0;
}//main end.
//---------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment