Documentos de Académico
Documentos de Profesional
Documentos de Cultura
#include <iostream>
using namespace std;
int main()
{
int x = 0;
int y[5] = { 0 };
Punto 2
#include <iostream>
#include <string>
using namespace std;
int main()
{
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 };
if (x % 2 == 0) {
A[x] = A[x] * 1;
}
else
A[x] = A[x] * -1;
sum = sum + A[x];
}
punto 6
#include <iostream>
using namespace std;
int main()
{
int x = 0, cont = 0;
int A[10] = { 0 }, B[10] = { 0 };
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;
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) {
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;