menor nota. Hacer un programa para ingresar las notas de los 4 exmenes y
reportar la nota eliminada y el promedio final del alumno
#include<iostream>
using namespace std;
#include<iostream>
using namespace std;
int i,n;
float x,t=1,s=1;
ingreso(n,x);
sumatoria(n,x,t,s);
return 0;
}
}
cout<<"La suma es: "<<s<<endl;
}
#include <iostream>
using namespace std;
int a, b, c = 0;
cout<<"primer rango : ";
cin>>a;
cout<<"segundo rango : ";
cin>>b;
while(a <= b)
if(esPrimo(a++))
c++;
cout<<"\nCantidad de primos: "<<c<<endl;
return 0;
}
bool esPrimo(int n)
{
if(n == 2)
return true;
if(!(n % i))
return false;
return true;
}
#include <iostream>
using namespace std;
int i;
float a,b;
IngresoFraccion(a,b);
Simplificar( a, b, i);
cout<<"La fraccion Simplificada es "<<a<<" / "<<b<<endl;
return 0;
}
void IngresoFraccion(int a, int b)
{
cout<<" Ingrese Numerador : ";
cin>>a;
b=b/i;
}
else
i=i+1;
}
return a,b;
}
5) Dado un numero entero positivo N, dibujar el siguiente triangulo:
Si N=5 saldr
1
12
123
1234
12345
#include <iostream>
using namespace std;
int n,nro=1;
Ingresa (n, nro);
return 0;
}
cout<<nro<<endl;
}
cout<<endl;
}
}
6) Ingresar n elementos en un vector y luego ingresar un elemento y reportar
cuantas veces aparece ese elemento en el vector.
#include<iostream>
#include <cstdio>
using namespace std;
#define MAX 100
reporteVector(x,n,"Vector Ingresado");
numerorepetido (x,n);
return 0;
}
void numDatos(int &n,char mensaje[])
{
do{
cout<<mensaje;
cin>>n;
}while(n<=0 || n>MAX);
}
void ingresoVector(float v[], int n,char mensaje[])
{
int i;
cout<<mensaje<<endl;
for(i=0;i<n;i++)
{
cout<<"v["<<i<<"]:";
cin>>v[i];
}
}
{cin>>v[i] ;
}
for(int i=0;i<n;i++)
{int cont=0;
for(int j=0;j<n;j++)
{
if (v[i]==v[j]) cont++;
}
cout<<"el dato: "<< v[i]<<"se repite: "<< cont<<" veces en el array"<<endl;
}
}
7) Ingresar dos vectores y reportar si son iguales
#include <iostream>
using namespace std;
int v1[20],v2[20];
return 0;
}
for(int i=1;i<=5;i++)
{
}
for(int i=1;i<=5;i++)
{
cout<<"ingrese valor para vector2: ";
cin>>v2[i];
}
}
void Compara(int v1[], int v2[] )
{
if(v1==v2)
cout<<"Los vectores son iguales ";
else
cout << "Los Vectores no son iguales " ;
#include <iostream>
using namespace std;
int n;
Ingreso( n, valor);
}
}
sp=sp+peso[i];
}
return sv/sp;
}
9) Ingrese los nombres y las notas de n alumnos y reportar una lista en orden
alfabtico y otra lista en orden de mrito.
#include<iostream>
#define LIM 100
using namespace std;
return 0;
}
void numDatos(int &n)
{
do{
cout<<"Numero de alumnos : ";
cin>>n;
}while(n<0 || n>LIM);
}
void ingreso(char nombres[][80], float notas[], int n)
{
int i;
for(i=0;i<n;i++)
{
cin.ignore();
cout<<"Ingrese nombre : ";
cin.getline(nombres[i],80);
cout<<"Ingrese nota : ";
cin>>notas[i];
}
}
void reporte(char nombres[][80], float notas[], int n)
{
int i;
for(i=0;i<n;i++)
cout<<nombres[i]<<", "<<notas[i]<<endl;
}
void ordenAlfabetico(char nombres[][80], float notas[], int n)
{
int i,j;
char temp1[80];
float temp2;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(strcmp(nombres[i],nombres[j])>0)
{
strcpy(temp1,nombres[i]);
strcpy(nombres[i],nombres[j]);
strcpy(nombres[j],temp1);
temp2=notas[i];
notas[i]=notas[j];
notas[j]=temp2;
}
}
void ordenMerito(char nombres[][80], float notas[], int n)
{
int i,j;
char temp1[80];
float temp2;
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(notas[i]<notas[j])
{
strcpy(temp1,nombres[i]);
strcpy(nombres[i],nombres[j]);
strcpy(nombres[j],temp1);
temp2=notas[i];
notas[i]=notas[j];
notas[j]=temp2;
}
}