Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Ejercicio 3:
#include <iostream>
using namespace std;
const int MAX=30;
void func1(int n, int num[MAX]);
void func2(int n, int num[]);
void func3(int n, int *num);
int main()
{
int i, n, num [MAX];
cout << "Cuantos datos enteros para el arreglo?" << endl;
cin>>n;
cout<<"ingrese "<<n<<" datos:"<<endl;
for (i=0; i<n; i++)
cin>>num[i];
cout<<"\n Llamada a func1().como un array delimitado:"<<endl;
func1(n,num);
cout<<"llamada a func2(). Como un array no delimitado:"<<endl;
func2(n,num);
cout<<"llamada a func3. como una referencia o puntero:"<<endl,
func3(n,num);
return 0;
}
void func1 (int n, int num [MAX])
{
for(int i=0; i<n; i++)
cout<<num[i]<<" ";
cout<<endl;
}
void func2 (int n, int num [])
{
for(int i=0; i<n; i++)
cout<<num[i]<<" ";
cout<<endl;}
void func3 (int n, int *num )
{
for(int i=0; i<n; i++)
cout<<num[i]<<" ";
cout<<endl;
}
Ejercicio 4:
#include <iostream>
#include <cmath>
const int MAX=50;
void leerPuntos(float a[], float b[], int n);
void escribirpuntos(float a[], float b[], int n);
void distancias(float a[], float b[], int n);
using namespace std;
int main()
{
int n;
float x[MAX], y[MAX];
cout << "cuantos puntos en el array?:"<< endl;
cin>>n;
/*leerPuntos(x,y,n);
escribirpuntos(x,y,n);
distancias(x,y,n);*/
return 0;
}
void leerPuntos(float a[], float b[], int n)
{
cout<<"\nIngrese "<<n<<" puntos y sus respectivas coordenadas"<<endl;
for (int i=0; i<n; i++)
{
cout<<"coordenadas X e Y del punto "<<i+1<<" : ";
cin>>a[i]>>b[i];
}
}
void escribirpuntos(float a[], float b[], int n)
{
cout<<"\npuntos ingresados: "<<endl;
for ( int i=0; i<n; i++)
cout<<"Punto"<<i+1<<" :( "<<a[i]<<", "<<b[i]<<")"<<endl;
cout<<endl;
}
void distancias(float a[], float b[], int n)
{
float dist(n);
float max=-32767, min =32768;
float xmin, ymin, xmax, ymax;
}
if (dist[i]>max)
{max=dist[i];
xmax=a[i];
ymax=b[i];}
}
cout<<"distancia mas cercana al origen: "<<min<<endl;
cout<<"Se dio en el punto: ("<<xmin<<","<<ymin<<")"<<endl;
cout<<"\nDistancia mas lejana al origen: "<<max<<endl;
cout<<"se dio en el punto:("<<xmax<<","<<ymax<<")"<<endl<<endl;
}
#include <iostream>
using namespace std;
void leermatriz (int notas [5][4]);
int main()
{
int notas [5][4], mayor;
cout << "ingreso de notas" << endl;
leermatriz(notas);
escribematriz(notas);
mayor = mayornota(notas);
cout<<"la mayor nota es:"<<mayor1
1
<<endl;
promalum(notas);
promcurso(notas);
return 0;
}
void leermatriz(int notas[5][4])
{
for(int i=0; i<5; i++)
{for(int j=0; j<4; j++)
{
cout<<"ingrese nota ("<<i<<")("<<j<<"):";
cin>>notas[i][j];
}
}
}
void escribematriz(int notas [5][4])
{ //int mayor;
for(int i=0; i<5; i++)
{for(int j=0; j<4; j++)
cout<<notas[i][j]<<" ";
cout<<endl;
}
//return mayor;
}
int mayornota(int notas[5][4])
{
int mayor=-100;
for (int i=0; i<5; i++)
{for(int j=0; j<4;j++)
{
if (notas[i][j])
mayor=notas[i][j];
}
}
return mayor;
}
float prom;
#include <iostream>
#include <stdlib.h>
using namespace std;
const int MAX=20;
void leer_mat (int n, int elem[][MAX]);
void escribe_mat (int n, int elem[][MAX]);
void suma_mat (int n, int a[][MAX], int b[][MAX], int s[][MAX]);
void leer_mat(int elem[MAX][MAX], int n)
{
cout << "Ingrese "<<n<<"datos por fila:\n"<<endl;
for (int i=0; i<n; i++)
{ cout<<"fila "<<i<<" ";
for (int j=0; j>n; j++)
cin>>elem[i][j];
}
}
void escribe_mat(int elem[MAX][MAX], int n)
{
for (int i=0; i<n; i++)
{
for (int j=0; j<n; j++)
{
cout<<elem[i][j]<<" ";
}
cout<<endl;
}
}
void suma_mat(int a[][MAX], int b[][MAX], int s[][MAX], int n)
{
for (int i=0; i<n; i++)
{
for (int j=0; j<n; j++)
s[i][j]=a[i][j]+b[i][j];
}
}
int main ()
{
int a[MAX][MAX], b[MAX][MAX], s[MAX][MAX], n;
#include <iostream>
using namespace std;
const int MAX=20;
void leer_mat (int elem[][MAX], int n, int m);
void escribe_mat (int elem[][MAX], int n, int m );
void prod_mat (int a[][MAX], int b[][MAX], int s[][MAX], int p[][MAX], int n, int l,
int m );
void leer_mat(int elem[MAX][MAX], int n, int m)
{
int main()
{
int n, x[MAX], p;
float a[MAX][MAX];
cout << "\nNorma euclidiana del vector X="<<norma(x,n)<< endl;
cout<<"Ingree el valor de p: ";
cin>>p;
cout<<"\nNorma-"<<p<<"del vector x ="<<norma(x,n,p)<<endl;
cout<<"\nIngrese orden N de la matriz: ";
cin>>n;
cout<<"Matriz A: ";
leer_mat(n,a);
cout<<"\nNorma euclidiana de la matriz A = "<<norma(a,n)<<endl;
cout<<"\nNorma maxima de la columna suma= "<<norma(a,n)<<endl;
return 0;
}
void leer_vect(int x[], int n)
{
cout<<"Ingrese "<<n<<"datos para el vector:\n";
for (int i=0; i<n; i++)
cin>>x[i];
}
void leer_mat(int n, float elem[][MAX])
{ cout<<"Ingrese "<<n<<" datos por fila:\n";
for (int i=0; i<n; i++)
{
cout<<"Fila "<<i<<": ";
for (int j=0; j<n; j++)
cin>>elem[i][j];
}
}