Está en la página 1de 6

/*

**********************************
* TEMA: Punteros y Vectores
* Nombre: Ranilla Coaguila Victor Andre *
* Cdigo: 2465
Grupo: 10
* Curso: Mecnica Computacional
***************************************
*/

*
*

// *** ARCHIVOS DE CABECERA ***


#include <iostream>
using namespace std;
// *** FUNCIONES Y PROCEDIMIENTOS ***
void ing_vector(double vector[], int c) // Ingresar vector
{
int i;
i = 0;
while (i<c)
{
cout << "- pos[" << i << "] = ";
cin >> vector[i];
}
i++;
}
void visu_vector(double vector[], int c) // Visualizar vector
{
int i = 0;
while (i < c)
{
cout << "\t[" << vector[i] << "]";
cout << "\n";
i++;
}
cout << "\n";
}
void suma_vector(double vec1[], double vec2[], double vec3[], int c) // Sumar vector
{
int i;
i = 0;
while (i < c)
{
vec3[i] = vec1[i] + vec2[i];
cout << "\t[" << vec3[i] << "]";
cout << "\n";
i++;
}
}
void buscar_vector(double vector[], int c) // Buscar un dato en el vector
{
int i, imp = 0, nBus;
i = 0;
cout << "Ingrese numero a buscar";
cin >> nBus;
while (i<c)
{

if (nBus == vector[i])
{
cout << " En Pos[" << i << "]\t";
imp++;
}
i++;
}
cout << "Repeticiones : " << imp << endl;
}
void ing_matriz(double matriz[][5], int f, int c) // Ingresar matriz
{
int i, j;
i = 0;
while (i < f)
{
j = 0;
while (j < c)
{
cout << "- pos[" << i << "][" << j << "] = ";
cin >> matriz[i][j];
j++;
}
i++;

void visu_matriz(double matriz[][5], int f, int c) // Visualizar matriz


{
int i = 0, j;
while (i < f)
{
j = 0;
while (j< c)
{
cout << "\t[" << matriz[i][j] << "]";
j++;
}
cout << "\n";
cout << endl;
i++;
}
cout << "\n";
}
void suma_matriz(double mat1[][5], double mat2[][5], double mat3[][5], int f, int c) //
Sumar matriz
{
int i, j;

i = 0;
while (i < f)
{
j = 0;
while (j<c)
{
mat3[i][j] = mat1[i][j] + mat2[i][j];
cout << "\t[" << mat3[i][j] << "]";
j++;
}
cout << "\n";
cout << endl;
i++;
}
}
void visu_fil_col(double matriz[][5], int f, int c) // Visualiza una fila y columna especfica
{
int i, j, fimp, cimp;
i = 0;
cout << "Ingrese fila";
cin >> fimp;
cout << "Ingrese columna";
cin >> cimp;
while (i < f)
{
j = 0;
while (j<c)
{
if (i == fimp || j == cimp)
{
cout << "\t[" << matriz[i][j] << "]";
}
else
{

cout << "\t ";

j++;
}
cout << "\n";
cout << endl;
i++;

}
void visu_diag_principal(double matriz[][5], int f, int c) // Visualiza la diagonal (i==j)
{
int i, j;
i = 0;
while (i < f)

{
j = 0;
while (j<c)
{
if (i == j)
{
cout << "\t[" << matriz[i][j] << "]";
}
else
{
}

cout << "\t ";

j++;
}
cout << "\n";
cout << endl;
i++;
}
}
void visu_diag_inversa(double matriz[][5], int f, int c) // Visualiza la diagonal inversa
{
int i, j, r;
i = 0;
r = f - 1;
while (i <f)
{
j = 0;
while (j<c)
{
if (i + j == r)
{
cout << "\t[" << matriz[i][j] << "]";
}
else
{
}

}
}

j++;
}
cout << "\n";
cout << endl;
i++;

cout << "\t ";

void buscar_matriz(double matriz[][5], int f, int c) // Busca elemento en matriz


{
int i, j, imp = 0, nBus;
i = 0;
cout << "Ingrese numero a buscar";
cin >> nBus;
while (i<f)
{
j = 0;
while (j<c)
{
if (nBus == matriz[i][j])
{
cout << " En Pos[" << i << j << "]\t";
imp++;
}
j++;
}
i++;
}
cout << "Repeticiones : " << imp << endl;
}
// Escriba las siguientes funciones
long double factorial(double nro)
{
long double res;
int i = 1;
res = 1;
while (nro >= i)
{
res = res*i;
i++;
}
return(res);
}
int primo(int nro)
{
int resul, res = 0, div;

div = nro;
while (div > 0)
{
resul = nro%div;
if (resul == 0)
{
res = res + 1;
}
div = div - 1;
}
return(res);

int nro_perfecto(int nro)


{
int div, r, res = 0;
div = nro;
while (div >= 1)
{
r = nro%div;
if (r == 0)
{
res = res + div;
}
div = div - 1;
}
res = res - nro;
return(res);
}
int cubo_perfecto(int nro)
{
int res = 0, cub;
while (nro != 0)
{
cub = nro % 10;
res = res + cub*cub*cub;
nro = nro / 10;
}
}

return(res);

int inv_numero(int nro)


{
int res = 0, c;
while (nro != 0)
{
c = nro % 10;
res = res * 10 + c;
nro = nro / 10;
}
return(res);
}
// *** PROGRAMA PRINCIPAL ***
void main()
{
}

system("pause");

También podría gustarte