martes, 19 de marzo de 2013

Practica 12

Problema 1
#include <iostream.h>
#include <conio.h>
void imprimeCaracter(char ch, int n);
int main ()
{
char caracter;
int x;
cout<<"Introduce el caracter a imprimir = ";
cin>>caracter;
cout<<"\nIntroduce la cantidad de caracteres = ";
cin>>x;
imprimeCaracter (caracter, x);
int a, b;
cout<<"\n\nIntroduce dos valores enteres = "<<endl;
cin>>a>>b;
int suma=a+b;
cout<<"\nEl resultado de la suma esta representada por el caracter * \n";
imprimeCaracter('*',suma);
getch ();
return 0;
}
void imprimeCaracter(char ch, int n)
{
int i;
for (i=1; i<=n; i++)
{
cout<<ch;
}
cout<<endl;
}






Problema 2

/*Practica No. 12 Problema 2 Fecha:4/03/2013
Integrantes: Jesus Hernan Valdez Meza*/
 #include <iostream.h>
#include <conio.h>
void imprimeAsteriscos ();
int mayor (int, int);
int menor (int, int);
int main ()
{
int a, b;
cout<<"Introduce dos valores enteros "<<endl;
cin>>a>>b;
imprimeAsteriscos ();
cout<<"El dato mayor es "<<mayor(a,b)<<endl<<endl;
imprimeAsteriscos ();
cout<<"El dato menor es "<<menor(a,b)<<endl<<endl;
imprimeAsteriscos ();
getch ();
return 0;
}
void imprimeAsteriscos ()
{
int j;
for (j=1; j<=30; j++)
{
cout<<"*";
}
cout<<endl<<endl;
}
int mayor(int x, int y)
{
if (x>y)
{
return x;
}
else
{
return y;
}
}
int menor (int x, int y)
{
if (x<y)
{
return x;
}
else
{
return y;
}
}




Problema 3

 #include <iostream.h>
#include <conio.h>
#include <stdlib.h>
void lecturaDatos (int a [10])
{
int i;
for (i=0; i<10; i++)
{
cout<<"numero["<<(i+1)<<"] = ";
cin>>a[i];
}
}
void desplegarDatos (int a [10])
{
int i;
cout<<"Listado de 10 valores enteros \n";
for (i=0; i<10; i++)
{
cout<<a[i]<<endl;
}
}
int sumaValores(int a [10])
{
int i, suma=0;
for (i=0; i<10; i++)
{
suma=suma+a[i];
}
return suma;
}
void mayorValores (int a [10])
{
int mayor=a[0];
int pos=0;
for ( int i=1; i<10; i++)
{
if (a[i]>mayor)
{
mayor=a[i];
pos=i;
}
}
cout<<"El dato mayor es "<<mayor<<endl;
cout<<"Su posicion en el arreglo es "<<pos+1<<endl;
}
void main ()
{
int numeros [10];
lecturaDatos (numeros);
cout<<endl<<endl;
desplegarDatos (numeros);
cout<<"\nLa suma total es "<<sumaValores(numeros)<<endl;
mayorValores (numeros);
getch ();
}

No hay comentarios:

Publicar un comentario