Imprimir la diagonal principal y secundaria de este código
Publicado por Juan (1 intervención) el 09/05/2020 20:43:50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <windows.h>
#include <iostream>
#include <conio.h>
using namespace std;
int gotoxy(USHORT x,USHORT y){
COORD cp={x,y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),cp);
}
void DIAGONALPRINCIPAL (int ARRIVE [10][10];)
void TITLES();
int MENU();
void CREATE( int ARRIVE[10][10], int NF, int NC );
void QUERY( int ARRIVE[10][10], int NF, int NC );
main()
{
char CONTROL = 'S';
int OPTION, N, M ;
int MATRIZ[10][10];
while ( CONTROL == 'S')
{
TITLES();
OPTION = MENU();
switch (OPTION) {
case 1 : TITLES();
gotoxy(26,9) ; cout << "ASIGNAR VALORES A LA MATRIZ";
do {
gotoxy(15,13); cout << "Numero de Filas, Max = 10 : ";
gotoxy(52,13); cin >> N;
}
while ((N < 0 ) || (N > 10));
do {
gotoxy(15,14); cout << "Numero de Columnas, Max = 10 : ";
gotoxy(52,14); cin >> M;
}
while ((M < 0 ) || (M > 10));
gotoxy(15,13); cout << " ";
gotoxy(15,14); cout << " ";
CREATE(MATRIZ, N, M);
break;
case 2 : QUERY(MATRIZ, N, M);
break;
case 3 : CONTROL = 'N';
};
}
}
//---------------------------------------------------------------------------------------------------
void TITLES()
{
system("cls");
system("color F1");
gotoxy(26,6); cout <<"CREAR E IMPRIMIR UNA MATRIZ 10X10";
}
//-----------------------------------------------------------------------------------------------------
int MENU()
{
int OP;
gotoxy(36,8); cout <<"MENU";
gotoxy(26,10); cout << "1 - CAPTURAR VALORES A LA MATRIZ" ;
gotoxy(26,11); cout << "2 - IMPRIMIR MATRIZ ";
gotoxy(26,12); cout << "3 - SALIR DEL PROGRAMA";
do {
gotoxy(24,16); cout << "Seleccine una alternativa : [ _ ]";
gotoxy(55,16); cin >> OP ;
}
while
(( OP < 1 ) || ( OP > 3));
return OP;
}
//------------------------------------------------------------------------------------------------------------
void CREATE( int ARRIVE[10][10], int NF, int NC )
{
int K, I ;
TITLES();
gotoxy(26,7); cout <<"CAPTURAR VALORES A LA MATRIZ";
for ( I = 0 ; I < NF ; I++ )
{
gotoxy(15,19); cout << "Digite valor entre 0 - 99 ";
for ( K = 0 ; K < NC ; K++ )
{
do
{
gotoxy(15,15); cout << "Introdusca un valor [ ]" ;
gotoxy(37,15); cin >> ARRIVE[I][K] ;
gotoxy(15,19); cout << "ERROR ......Digite valor entre 0 - 99 ";
}
while ((ARRIVE[I][K] < 0) || (ARRIVE[I][K] > 99 )) ;
gotoxy(15,19); cout << "Digite valor entre 0 - 99 ";
}
}
}
//-------------------------------------------------------------------------------------------------------------
void QUERY( int ARRIVE[10][10], int NF, int NC )
{
int VECTOR[10],I, K, F, j, N;
TITLES();
gotoxy(21,7) ; cout << "IMPRIMIR LA MATRIZ " ;
F = 11 ;
gotoxy(20,F); cout << "MATRIZ = ";
for ( I = 0 ; I < NF ; I++ )
{
VECTOR[I] = 0;
gotoxy(30,F) ;
for ( K = 0 ; K < NC ; K++ )
{
printf ("%3d %3s", ARRIVE[I][K], " ") ;
VECTOR[I] = VECTOR[I] + ARRIVE[I][K];
}
F++;
}
gotoxy(20,F+3); cout << "Pulse cualquier tecla para salir";
getch();
}
Valora esta pregunta


0