me estan pidiendo buscar el menor y el mayor de las líneas de MbR
Publicado por Hasley (2 intervenciones) el 27/07/2020 04:53:16
Buenas por favor quisiera saber ¿Cómo hago esto? Yo lo hice buscando el mayor pero ese busca el mayor en toda las filas y me estan pidiendo buscar el menor y el mayor de las líneas de MbR y que se realizará solo restando los Mbu y MbO.
Esto es todo lo que llevo por ahora
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
#include<iostream>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
using namespace std ;
void inicializacion ( int m [ ] [ 10 ] , int nf , int nc )
{
for ( int f = 0 ; f < nc ; f ++ )
{
for ( int c = 0 ; c < nf ; c ++ )
{
m [ f ] [ c ] = 0 ;
}
}
}
void llenar ( int m [ ] [ 10 ] , int nf , int nc )
{
for ( int f = 0 ; f < nc ; f ++ )
{
for ( int c = 0 ; c < nf ; c ++ )
{
cout << " Ingrese los elementos ( " << f << ", " << c << " ) " ; // le pedimos al usuario que ingrese los elementos
cin >> m [ f ] [ c ] ;
}
}
}
void mostrar ( int m [ ] [ 10 ] , int nf , int nc )
{
cout << endl ;
cout << endl ;
cout << " La matriz es : " << endl ;
cout << " \t \t \t \t \t Linea 1 \t \t Linea 2 \t \t Linea 3 \t \t \t " << endl ;
cout << " \t \t Cliente \t Mbo \t MbU \t MbR \t Mbo \t MbU \t MbR \t Mbo \t MbU \t MbR" << endl ;
for ( int c = 0 ; c < nf ; c ++ )
{
cout << " \t \t " ;
for ( int f = 0 ; f < nc ; f ++ )
{
cout << " \t " << m [ f ] [ c ] ;
}
cout << endl ;
}
cout << endl ;
}
void mayor_elemento_fila ( int m [ ] [ 10 ] , int nf , int nc , int & p )
{
float max = m [ 0 ] [ 0 ] ;
int ind = 0 , ind1 = 0 ;
cout << " Cual fila quiere buscar ? " << endl ;
cin >> p ;
for ( int f = 1 ; f < nc ; f ++ )
{
for ( int c = 1 ; c < nf ; c ++ )
{
if ( max < m [ f ] [ c ] )
{
max = m [ p ] [ c ] ;
ind = f ;
ind1 = c ;
}
}
}
cout << " El maximo elemento de esta fila es : " << max << " " << " y esta en el indice : [ " <<
ind << " ] [ " << ind1 << " ] " << endl ;
}
main ()
{
int matriz [ 3 ] [ 10 ] , p ;
inicializacion ( matriz , 3 , 10 ) ;
llenar ( matriz , 3 , 10 ) ;
mostrar ( matriz , 3 , 10 ) ;
mayor_elemento_fila ( matriz , 3 , 10 , p ) ;
getch () ;
}
Valora esta pregunta
0