problem whith c++ program

can execute this program,if somone can help please...

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <iostream>
#include "Matrix.cpp"
#include "matriz.h" /* Ficheiro de interface do TAD */

#define MAX_MATRIZES 14

void Menu (void);
void LerOpcao (int *);
void LerIndiceMatriz (int *, char *);
int MatrizActiva (PtMatriz *, int);
int MatrizNaoActiva (PtMatriz *, int);
void LerDimensaoMatriz (unsigned int *, unsigned int *);
void LerNomeFicheiro (char *);
void EscreverMensagemErro (char *);
PtMatriz LerMatriz (unsigned int, unsigned int);
void EscreverMatriz (PtMatriz *, int);
void AlterarMatriz (PtMatriz);

int main (void)
{
PtMatriz Matrizes[MAX_MATRIZES];
int Opcao, l, Matriz1, Matriz2, Matriz3, Comp; unsigned int NL, NC;
char NomeFicheiro[21];

for (l = 0; l < MAX_MATRIZES; l++) Matrizes[l] = NULL;

do
{

/* limpar o ecran e apresentar menu */
Menu ();

/* limpar o erro entretanto ocorrido */
InicializarErroMatriz ();

/* apresentar as matrizes activas */
for (l = 0; l < MAX_MATRIZES; l++)
if (Matrizes[l] != NULL)
{
DimensaoMatriz (Matrizes[l], &NL, &NC);
printf ("\e[1m\e[%d;47f Matriz %d x %d", 5+l, NL, NC);
printf ("\e[0m");
}

/* ler opcao do utilizador */
LerOpcao (&Opcao);


switch (Opcao)
{
case 1 : LerIndiceMatriz (&Matriz1, "matriz");
if (MatrizActiva (Matrizes, Matriz1)) break;
LerDimensaoMatriz (&NL, &NC);
Matrizes[Matriz1] = LerMatriz (NL, NC);
if (ErroMatriz ()) EscreverMensagemErro ("A criação");
break;

case 2 : LerIndiceMatriz (&Matriz1, "matriz");
if (MatrizActiva (Matrizes, Matriz1)) break;
LerNomeFicheiro (NomeFicheiro);
Matrizes[Matriz1] = CriarMatrizFicheiro (NomeFicheiro);
if (ErroMatriz ()) EscreverMensagemErro ("A leitura");
break;

case 3 : LerIndiceMatriz (&Matriz1, "matriz origem");
do
{
LerIndiceMatriz (&Matriz2, "matriz destino");
} while (Matriz2 == Matriz1);
if (MatrizActiva (Matrizes, Matriz2)) break;
Matrizes[Matriz2] = MatrizTransposta (Matrizes[Matriz1]);
if (ErroMatriz ()) EscreverMensagemErro ("A transposição");
break;

case 4 : LerIndiceMatriz (&Matriz1, "primeira matriz");
LerIndiceMatriz (&Matriz2, "segunda matriz");
do
{
LerIndiceMatriz (&Matriz3, "matriz soma");
} while (Matriz3 == Matriz1 || Matriz3 == Matriz2);
if (MatrizActiva (Matrizes, Matriz3)) break;
Matrizes[Matriz3] = SomarMatrizes (Matrizes[Matriz1], Matrizes[Matriz2]);
if (ErroMatriz ()) EscreverMensagemErro ("A adição");
break;

case 5 : LerIndiceMatriz (&Matriz1, "primeira matriz");
LerIndiceMatriz (&Matriz2, "segunda matriz");
do
{
LerIndiceMatriz (&Matriz3, "matriz produto");
} while (Matriz3 == Matriz1 || Matriz3 == Matriz2);
if (MatrizActiva (Matrizes, Matriz3)) break;
Matrizes[Matriz3] = MultiplicarMatrizes (Matrizes[Matriz1], Matrizes[Matriz2]);
if (ErroMatriz ()) EscreverMensagemErro ("A multiplicação");
break;

case 6 : LerIndiceMatriz (&Matriz1, "primeira matriz");
LerIndiceMatriz (&Matriz2, "segunda matriz");
Comp = CompararMatrizes (Matrizes[Matriz1], Matrizes[Matriz2]);
if (ErroMatriz ()) EscreverMensagemErro ("A comparação");
else
{
if (Comp) printf("\e[26;1f| \e[1mAs matrizes %d e %d são iguais", Matriz1, Matriz2);
else printf("\e[26;1f| \e[1mAs matrizes %d e %d não são iguais", Matriz1, Matriz2);
printf("\e[0m\e[27;1f| Prima uma tecla para continuar ");
scanf ("%*[^\n]"); scanf ("%*c");
}
break;

case 7 : LerIndiceMatriz (&Matriz1, "matriz origem");
if (MatrizNaoActiva (Matrizes, Matriz1)) break;
do
{
LerIndiceMatriz (&Matriz2, "matriz destino");
} while (Matriz2 == Matriz1);
if (MatrizActiva (Matrizes, Matriz2)) break;
Matrizes[Matriz2] = CopiarMatriz (Matrizes[Matriz1]);
if (ErroMatriz ()) EscreverMensagemErro ("A cópia");
break;

case 8 : LerIndiceMatriz (&Matriz1, "matriz");
if (MatrizNaoActiva (Matrizes, Matriz1)) break;
LerNomeFicheiro (NomeFicheiro);
ArmazenarMatrizFicheiro (Matrizes[Matriz1], NomeFicheiro);
if (ErroMatriz ()) EscreverMensagemErro ("O armazenamento");
break;

case 9 : LerIndiceMatriz (&Matriz1, "matriz");
if (MatrizNaoActiva (Matrizes, Matriz1)) break;
AlterarMatriz (Matrizes[Matriz1]);
break;

case 10 : LerIndiceMatriz (&Matriz1, "matriz");
if (MatrizNaoActiva (Matrizes, Matriz1)) break;
EscreverMatriz (Matrizes, Matriz1);
printf("\e[1m\e[26;1f| Matriz %d ", Matriz1);
printf("\e[0m\e[27;1f| Prima uma tecla para continuar ");
scanf ("%*[^\n]"); scanf ("%*c");
break;

case 11 : LerIndiceMatriz (&Matriz1, "matriz");
if (MatrizNaoActiva (Matrizes, Matriz1)) break;
ApagarMatriz (&Matrizes[Matriz1]);
if (ErroMatriz ()) EscreverMensagemErro ("A destruição");
break;
}

} while (Opcao != 12);

for (l = 0; l < MAX_MATRIZES; l++)
if (Matrizes[l] != NULL) ApagarMatriz (&Matrizes[l]);

printf ("\e[29;1f");

return 0;
}


void LerIndiceMatriz (int *pnm, char *pmsg)
{
int MsgLen = strlen (pmsg);

do
{
*pnm = -1;
printf("\e[22;1f| Indice da %s -> ", pmsg);
printf("\e[22;%df", 17+MsgLen); scanf ("%d", pnm);
scanf ("%*[^\n]"); scanf ("%*c");
} while (*pnm < 0 || *pnm >= MAX_MATRIZES);
}

int MatrizActiva (PtMatriz pgrupom[], int pnm)
{
char Car;

if (pgrupom[pnm] != NULL)
{
do
{
printf("\e[1m\e[26;1f| A matriz %d já existe! ", pnm);
printf("\e[0m\e[27;1f| Deseja apagá-la (s/n)? ");
scanf ("%c", &Car); Car = tolower (Car);
scanf ("%*[^\n]"); scanf ("%*c");
} while (Car != 'n' && Car != 's');

if (Car == 's') { ApagarMatriz (&pgrupom[pnm]); return 0; }
else return 1;
}
else return 0;
}

int MatrizNaoActiva (PtMatriz pgrupom[], int pnm)
{
if (pgrupom[pnm] == NULL)
{
printf("\e[1m\e[26;1f| A matriz %d não existe! ", pnm);
printf("\e[0m\e[27;1f| Prima uma tecla para continuar ");
scanf ("%*[^\n]"); scanf ("%*c");
return 1;
}
else return 0;
}

void LerDimensaoMatriz (unsigned int *pnl, unsigned int *pnc)
{
do
{
*pnl = 0;
printf("\e[22;1f| Nº de linhas da matriz -> ");
printf("\e[22;29f"); scanf ("%d", pnl);
scanf ("%*[^\n]"); scanf ("%*c");
} while (*pnl < 1 || *pnl > 10);

do
{
*pnc = 0;
printf("\e[22;1f| Nº de colunas da matriz -> ");
printf("\e[22;30f"); scanf ("%d", pnc);
scanf ("%*[^\n]"); scanf ("%*c");
} while (*pnc < 1 || *pnc > 10);
}


void LerNomeFicheiro (char *pnf)
{
int Status;

do
{
printf("\e[22;1f| Nome do ficheiro -> ");
printf("\e[22;23f"); Status = scanf ("%20[^\n]", pnf);
scanf ("%*[^\n]"); scanf ("%*c");
} while (Status == 0);
}

void LerOpcao (int *popc)
{
do
{
*popc = 0;
printf("\e[18;1f| Opção -> |");
printf("\e[18;12f"); scanf ("%d", popc);
scanf ("%*[^\n]"); scanf ("%*c");
} while (*popc < 1 || *popc > 12);
}


THE CODE CONTINUE....
void EscreverMensagemErro (char *pmsg)
{
printf("\e[26;1f| %s de matrizes não foi efectuada devido a -> \e[1m%s", pmsg, MensagemErroMatriz ());
printf("\e[0m\e[27;1f| Prima uma tecla para continuar ");
scanf ("%*[^\n]"); scanf ("%*c");
}

PtMatriz LerMatriz (unsigned int pnl, unsigned int pnc)
{
PtMatriz Mat; unsigned int L, C; int Elemento, Status;

/* cria a matriz nula */
if ((Mat = CriarMatrizNula (pnl, pnc)) == NULL) return NULL;

/* leitura das componentes da matriz do teclado */
for (L = 0; L < pnl; L++)
{
for (C = 0; C < pnc; C++)
{
do
{
printf("\e[22;1f| Matriz[%d,%d]? ", L+1, C+1);
printf("\e[22;16f"); Status = scanf ("%d", &Elemento);
scanf ("%*[^\n]"); scanf ("%*c");
} while (Status == 0);
EscreverCompMatriz (Mat, L, C, Elemento);
}
}

return Mat; /* devolve a matriz criada */
}

void EscreverMatriz (PtMatriz pgrupom[], int pnm)
{
unsigned int L, C, NL, NC;

DimensaoMatriz (pgrupom[pnm], &NL, &NC);

printf("\e[1m");
for (L = 0; L < NL; L++)
{
printf("\e[%d;65f ", 6+L);
for (C = 0; C < NC; C++)
printf ("%4d ", LerCompMatriz (pgrupom[pnm], L, C));
}
printf("\e[0m");
}


}
void AlterarMatriz (PtMatriz pmat)
{
unsigned int L, C, NL, NC; char Car; int Elemento, Status;

DimensaoMatriz (pmat, &NL, &NC);

do
{
do
{
L = -1;
printf("\e[22;1f| Nº da linha do elemento da matriz -> ");
printf("\e[22;40f"); scanf ("%d", &L);
scanf ("%*[^\n]"); scanf ("%*c");
} while (L < 1 || L > NL);

do
{
C = -1;
printf("\e[22;1f| Nº da coluna do elemento da matriz -> ");
printf("\e[22;41f"); scanf ("%d", &C);
scanf ("%*[^\n]"); scanf ("%*c");
} while (C < 1 || C > NC);

do
{
printf("\e[22;1f| Matriz[%d,%d]? ", L, C);
printf("\e[22;16f"); Status = scanf ("%d", &Elemento);
scanf ("%*[^\n]"); scanf ("%*c");
} while (Status == 0);

EscreverCompMatriz (pmat, L-1, C-1, Elemento);
do
{
printf("\e[22;1f| Deseja alterar mais algum elemento da matriz (s/n)? ");
printf("\e[22;55f"); scanf ("%c", &Car); Car = tolower (Car);
scanf ("%*[^\n]"); scanf ("%*c");
} while (Car != 'n' && Car != 's');
} while (Car == 's');
what is your question ?
come on bluecoder... can't you just figure it out for him?
Topic archived. No new replies allowed.