Está en la página 1de 16

Punto 1

#include <iostream>
using namespace std;

int main()
{

int x = 0;
int y[5] = { 0 };

for (x = 0; x <5; x++)


{
cout << "ingrese dato en la posicion y[" << x << "]" << endl;
cin >> y[x];
}
for(x= 0; x<5; x++)
{
cout<<"|" << y[x]<< "|";
}
cout<<endl;
for(x= 0; x <5; x++)
{
cout<<"|" << y[4-x]<< "|";
}

Punto 2

#include <iostream>
#include <string>
using namespace std;

int main()
{

int x = 0,sum=0, mayor=0;


int Y[4] = { 0 };

for (x = 0; x <4; x++)


{
cout << "ingrese dato en la posicion y[" << x << "]" << endl;
cin >> y[x];
sum = sum + y[x];
if (y[x] > mayor)
{
mayor = y[x];
}
}

cout << "NUM | MAX-NUM" <<endl;


cout << "-----------------" <<endl;

for(x = 0; x <4; x++)


{
cout<<"|" << y[x]<< "|" <<" |" << mayor-y[x]<< "|"<<endl;
}
cout << endl;

Punto 3
#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
while (true) {
cout << "-----------------------------------------------------------------" << endl;
int cont = 0;
int num;
int a[9] = { 25,24,65,99,77,44,33,88,66 };
for (int x = 0; x <= 9; x++) {
cout << a[x] << " ";
}
cout << endl;
cout << "ingrese numero a buscar dentro del arreglo: " << endl;
cin >> num;
for (int x = 0; x < 10; x++) {
if (num == a[x]) {
cout << "el numero se encuentra en la posicion: " << x
<< endl;
}
if (a[x] != num) {
cont = cont+ 1;
}
}
if (cont == 10) {
cout << "el numero no existe dentro de la matriz" << endl;
}
}
return 0;
}
Punto 4
#include <iostream>
using namespace std;

int main()
{

int x = 0, sum = 0;
int A[9] = { 0 };

for (x = 0; x < 9; x++)


{
cout << "ingrese dato en la ñlposicion A[" << x << "]" << endl;
cin >> A[x];

if (x % 2 == 0) {
A[x] = A[x] * 1;
}
else
A[x] = A[x] * -1;
sum = sum + A[x];
}

for (x = 0; x < 9; x++)


{
cout << "|" << A[x] << "|";
}
cout << endl;
cout << "La suma de los elementos es: " << suma << endl;
}

punto 6
#include <iostream>
using namespace std;

int main()
{

int x = 0, cont = 0;
int A[10] = { 0 }, B[10] = { 0 };

for (x = 0; x < 10; x++)


{
cout << "ingrese numero: " << endl;
cin >> A[x];

if ((A[x] >= 10) && (A[x]<=40)){

cout << "Su numero esta dentro del rango contiene ...." << endl;

for(int y=0;y<x;y++){
if(A[x] == A[y]){
cout<< "iguales"<<endl;
--i;
}
}
cont=0;
}
else{
cout<<"No esta dentro del rango" << endl;
}
cout<<endl;

for (x = 0; x < 10; x++)


{
cout << x<<" -> " <<A[x]<<endl;
}
cout << endl;

Punto 7

include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
int costo = 0;
int opcion = 0;
int puest[9][10] = { 10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,
10,10,20,20,20,20,20,20,10,10,
10,10,20,20,20,20,20,20,10,10,
10,10,20,20,20,20,20,20,10,10,
20,20,30,30,40,40,30,30,20,20,
20,30,30,40,50,50,40,30,30,20,
30,40,50,50,50,50,50,50,40,30
};

while (true) {

for (int x = 0; x < 9; x++)


{
for (int y = 0; y < 10; y++) {
cout << puestos[x][y] << " ";
}
cout << endl;
}
inicio:
cout << "***************ESCOJA UNA OPCION:***************** " << endl;
cout << "opcion 1 : escoger un asiento." << endl;
cout << "opcion 2 : escoger un precio. " << endl;
cin >> opcion;
switch (opcion)
{
//------------------------------------------------------------------------------------
-----------------------------------------------------
case 1:
{
int fila = 0;
int columna = 0;
cout << "indique la fila : " << endl;
cin >> fila;
cout << "indique la columna :" << endl;
cin >> columna;
if (puest[fila][columna] != 0) {
for (int x = 0; x < 9; x++)
{
for (int y = 0; y < 10; y++) {

if (puest[fila][columna] == 10) {
costo = 10000;
}
if (puest[fila][columna] == 20) {
costo = 20000;
}
if (puest[fila][columna] == 30) {
costo = 30000;
}
if (puest[fila][columna] == 40) {
costo = 40000;
}
if (puest[fila][columna] == 50) {
costo = 50000;
}
puest[fila][columna] = 0;
cout << puest[x][y] << " ";
}
cout << endl;

}
cout << "----------------------------------------------------------------
--------------------------" << endl;
cout << "el precio del asiento escogido es :" << costo <<
endl;
cout << "el puesto elegido se encuentra en la fila " << fila
<< " en la columna " << columna << endl;
cout << "----------------------------------------------------------------
--------------------------" << endl;
goto inicio;
}
else {
cout << "el puesto escogido no se encuentra disponible"
<< endl;
goto inicio;
}
}
//----------------------------------------------------------------------------------------------
-----
case 2:
{
inicio1:
int puest1[9][10] = { 10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,
10,10,10,10,10,10,10,10,10,10,
10,10,20,20,20,20,20,20,10,10,
10,10,20,20,20,20,20,20,10,10,
10,10,20,20,20,20,20,20,10,10,
20,20,30,30,40,40,30,30,20,20,
20,30,30,40,50,50,40,30,30,20,
30,40,50,50,50,50,50,50,40,30
};
int costo = 0;
int fila = 0;
int columna = 0;
cout << "precios existentes: 10000 | 20000 | 30000 | 40000 |
50000" << endl;

cout << "indique el precio que deesea para su asiento:" << endl;
cin >> costo;
for (int x = 0;x< 9; x++)
{
for (int y = 0; y < 10; y++) {
if (costo == 10000) {
if (puest1[x][y] != 10)
{
puest1[x][y] = 0;

}
if (costo == 20000) {
if (puest1[x][y] != 20) {
puest1[x][y]= 0;

}
}
if (costo == 30000) {
if (puest1[x][y] != 30) {
puest1[x][y] = 0;

}
}
if (costo == 40000) {
if (puest1[x][y] != 40) {
puest1[x][y] = 0;

}
}
if (costo == 50000) {
if (puest1[x][y] != 50) {
puest1[x][y] = 0;

}
}
cout << puest1[x][y] << " ";
}
cout << endl;
}

cout << "indique la fila del asiento que desea elegir: " << endl;
cin >> fila;
cout << "indique la columna del asiento que desea elegir: " <<
endl;
cin >> columna;
for (int x = 0; x < 9; x++) {
for (int y = 0; y < 10; y++) {
if (puest1[fila][columna] != 0) {
puest[fila][columna] = 0;

}
else {
cout << "el puesto elegido no cumple con
el precio deseado:" << endl;
goto inicio1;
}

}
}
cout << "--------------------------------------------------------------------------
----------------" << endl;
cout << "el puesto escogido esta en la fila " << fila << "
columna " << columna << endl;
cout << "el precio a pagar es: " << costo << endl;
cout << "--------------------------------------------------------------------------
----------------" << endl;
}
//----------------------------------------------------------------------------------------------
-------------

}
return 0;
}

Punto 8

#include "stdafx.h"
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
cout << "----------------------------------------------------------|" << endl;
cout << "|DISTRITO | CANDIDATO |CANDIDATO |CANDIDATO |
CANDIDATO |" << endl;
cout << "| | a | b | c | d |" << endl;
cout << "----------------------------------------------------------|" << endl;
int matriz[5][5] = {1,194,48,206,45,
2,180,20,320,16,
3,221,90,140,20,
4,432,51,821,14,
5,820,61,946,18};
for (int x = 0; x < 5; x++) {
for (int y = 0; y < 5; y++) {
cout <<" "<< matriz[x][y]<<" ";
}
cout << endl;
}
cout << "----------------------------------------------------------|" << endl;
int a = 0;
a = matriz[0][1] + matriz[1][1] + matriz[2][1] + matriz[3][1] + matriz[4][1];
cout << "Total de votos CANDIDATO A: " <<a<< endl;

int b = 0;
b = matriz[0][2] + matriz[1][2] + matriz[2][2] + matriz[3][2] + matriz[4][2];
cout << "Total de votos CANDIDATO B: " << b << endl;

int c = 0;
c = matriz[0][3] + matriz[1][3] + matriz[2][3] + matriz[3][3] + matriz[4][3];
cout << "Total de votos CANDIDATO C: " << c << endl;

int d = 0;
d = matriz[0][4] + matriz[1][4] + matriz[2][4] + matriz[3][4] + matriz[4][4];
cout << "Total de votos CANDIDATO D: " << d << endl;

double total = a + b + c + d;
cout << " TOTAL de votos: " << total << endl;

double promedio = total / 4;


cout << "promedio por VOTANTE : " << promedio << endl;
double promedioa =( a*100) /total;
cout << "promedio de votos del CANDIDATO A: " << promedioa << endl;
double promediob =( b*100) / total;
cout << "promedio de votos del CANDIDATO B: " << promediob << endl;
double promedioc =( c*100) / total;
cout << "promedio de votos del CANDIDATO C: " << promedioc << endl;
double promediod= (d*100) / total;
cout << "promedio de votos del CANDIDATO D: " << promediod << endl;
if (promedioa > 50) {
cout << "¡¡ CANDIDATO A GANDOR !!" << endl;
}
if (promediob > 50) {
cout << "¡¡ CANDIDATO B GANDOR !!" << endl;
}
if (promedioc > 50) {
cout << "¡¡ CANDIDATO C GANDOR !!" << endl;
}
if (promediod > 50) {
cout << "¡¡ CANDIDATO D GANDOR !!" << endl;
}
//--------------------------------------------------------------------------------------------------------
----------------------------------------
int caso = 1;
char mayor = ' ';
char mayor1 =' ';
switch (caso)
{
case 1:
{

if (a > b && a > c && a > d) {


mayor = 'a';
a = 0;
caso = 2;
}
if (b > a && b > c && b > d) {
mayor = 'b';
b = 0;
caso = 2;
}
if (c > b && c > a && c > d) {
mayor = 'c';
c = 0;
caso = 2;
}
if (d > b && d > c && d > a) {
mayor = 'd';
d = 0;
caso = 2;
}
}
//--------------------------------------------------------------------------------------------------------
------------------------------------------
case 2:
{
if (a > b && a > c && a > d) {
mayor1 = 'a';
a = 0;
break;
}
if (b > a && b > c && b > d) {
mayor1 = 'b';
b = 0;
break;
}
if (c > b && c > a && c > d) {
mayor1 = 'c';
c = 0;
break;
}
if (d > b && d > c && d > a) {
mayor1 = 'd';
d = 0;
break;
}
}
}
cout << "CANDIDATO EN EL PRIMER PUESTO PARA LASEGUNDA RONDA:
" << mayor << endl;
cout << "CANDIDATO EN EL SEGUNDO PUESTO PARA LASEGUNDA
RONDA: " << mayor1 << endl;
return 0;
}

También podría gustarte