Академический Документы
Профессиональный Документы
Культура Документы
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
/*
1. Leer 10 enteros, almacenarlos en un vector y determinar en qu posicin del vector est
el mayor nmero ledo.
*/
int A[9], f, c, d;
cout << "Ingrese 10 numeros enteros: \n";
for (int i = 0; i <= 9; i++) {
cin >> A[i];
}
d = 1;
f = A[0];
for (int b = 0; b <= 9; b++) {
if (f > A[b]) {
}
else {
f = A[b];
}
}
for (c = 0; c <= 9; c++) {
if (f == A[c]) {
break;
}
else {
d++;
}
}
cout << " El mayor de los numeros es " << f << " y su posicion es " << d << endl;
system("pause");
}
2. Leer 10 enteros, almacenarlos en un vector y determinar en qu
posicin del vector est el mayor nmero par ledo.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
/*Leer 10 enteros, almacenarlos en un vector y determinar en qu posicin del vector est el
mayor nmero par ledo.
*/
int A[9];
int B[9];
int b = 0, f=0,n=0,t=1;
cout << "Ingrese 10 numeros enteros: " << endl;
for (int i = 0; i <= 9; i++) {
cin >> A[i];
}
f = A[0];
for (int i = 0; i <= 9; i++) {
}
else {
if (A[i] % 2 == 0) {
f = A[i];//Esta variable va a contener el numero par mayor
}
}
}
for (b = 0; b <= 9; b++) {
if (f == A[b]) {
break;
}
else {
t++; //Esta variable va a contener la posicion
}
}
cout <<"El numero par mayor es: "<< f <<" y su posicion es " <<t<< endl;
system("pause>null");
}
3. Leer 10 enteros, almacenarlos en un vector y determinar en qu
posicin del vector est el mayor nmero primo ledo.
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
int main()
{inicio:
cout << " \n" << max << " es el numero primo mayor y pertenece a la posicion :" << x ;
system("pause");
system("cls");
goto inicio;
return 0;
}
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
system("pause");
//Almacenar en un vector de 10 posiciones los 10 nmeros primos comprendidos entre 100 y 300.
Luego mostrarlos en pantalla.
int c = 0, b = 0;
int n[9];
for (int i = 100; i <= 300; i++) {
for (int x = 1; x <= i; x++) {
if ((i % x == 0)) {
c++;
}
if ((c > 2) && (i == x )) {
c=0;
}
}
if (c == 2) {
n[b] = i;
b++;
}
}
cout << "Los 10 primeros numeros primos entre 100 y 300 son: " << endl;
while (c != 10) {
system("pause");
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
/*Leer dos nmeros enteros y almacenar en un vector los 10 primeros nmeros primos
comprendidos entre el menor y el mayor.
Luego mostrarlos en pantalla. */
int n1, n2;
cout << "Ingrese un numero entero: ";
cin >> n1;
cout << "Ingrese otro numero: ";
cin >> n2;
if ((i % x == 0)) {
c++;
}
if ((c > 2) && (i == x)) {
c = 0;
}
}
if (c == 2) {
n[b] = i;
b++;
}
}
cout << "Los 10 primeros numeros primos entre "<< n1<< " y " << n2<<" son: " << endl;
while (c != 10) {
}
else {
int c = 0, b = 0;
int n[9];
for (int i = n2; i <= n1; i++) {
for (int x = 1; x <= i; x++) {
if ((i % x == 0)) {
c++;
}
if ((c > 2) && (i == x)) {
c = 0;
}
}
if (c == 2) {
n[b] = i;
b++;
}
}
cout << "Los 10 primeros numeros primos entre " << n2 << " y " << n1 << " son: " << endl;
while (c != 10) {
system("pause");
return 0;
}
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
/*
1. Leer 10 enteros, almacenarlos en un vector y determinar en qu posicin del vector est
el mayor nmero ledo.
*/
int A[9],f,c,d;
cout << "Ingrese 10 numeros enteros: \n";
for (int i = 0; i <= 9; i++) {
cin >> A[i];
}
d = 0;
f = A[0];
for (int b = 0; b <= 9; b++) {
if (f > A[b]) {
}
else {
f = A[b];
}
for ( c = 0; c <= 9; c++) {
if (f == A[b]) {
d++;
break;
}
}
cout << " El mayor de los numeros es " << f <<" y su posicion es "<<d<< endl;
system("pause");
return 0;
}
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
int main()
{
int nombres[9];
cout << "Por favor ingrese la siguiente informacin de los Libros: \n";
volver:
system("cls");
for (int i = 0; i <= 9; i++)
{
}
printf("\nLa posicion de los numeros terminados en 4 es --------- \n");
if (cin, nombres[0] % 10 == 4) {
printf("\nEn la posicion 1\n");
printf("\n");
}
if (cin, nombres[1] % 10 == 4) {
printf("\nEn la posicion 2\n");
printf("\n");
}
if (cin, nombres[2] % 10 == 4) {
printf("\nEn la posicion 3 \n");
printf("\n");
}
if (cin, nombres[3] % 10 == 4) {
printf("\nEn la posicion 4 \n");
printf("\n");
}
if (cin, nombres[4] % 10 == 4) {
printf("\nEn la posicion 5 \n");
printf("\n");
}
if (cin, nombres[5] % 10 == 4) {
printf("\nEn la posicion 6 \n");
printf("\n");
}
if (cin, nombres[6] % 10 == 4) {
printf("\nEn la posicion 7 \n");
printf("\n");
}
if (cin, nombres[7] % 10 == 4) {
printf("\nEn la posicion 8 \n");
printf("\n");
}
if (cin, nombres[8] % 10 == 4) {
printf("\nEn la posicion 9 \n");
printf("\n");
}
if (cin, nombres[9] % 10 == 4) {
printf("\nEn la posicion 10 \n");
printf("\n");
}
system("pause");
goto volver;
}
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
/*
9. Leer 10 nmeros enteros, almacenarlos en un vector y determinar cuntas veces est
repetido el mayor.
*/
int A[9], f, c, d;
cout << "Ingrese 10 numeros enteros: \n";
for (int i = 0; i <= 9; i++) {
cin >> A[i];
}
d = 0;
f = A[0];
for (int b = 0; b <= 9; b++) {
if (f > A[b]) {
}
else {
f = A[b];
}
}
for (c = 0; c <= 9; c++) {
if (f == A[c]) {
d++;
}
cout << " El mayor de los numeros es " << f << " se repite tantas veces " << d << endl;
system("pause");
int main()
{
int nombres[9];
cout << "Por favor ingrese la siguiente informacin de los Libros: \n";
volver:
system("cls");
for (int i = 0; i <= 9; i++)
{
}
printf("\nLa posicion de los numeros mas de 3 digitos es --------- \n");
if (cin, nombres[0] > 999) {
printf("\nEn la posicion 1\n");
printf("\n");
}
if (cin, nombres[1] > 999) {
printf("\nEn la posicion 2\n");
printf("\n");
}
if (cin, nombres[2] > 999) {
printf("\nEn la posicion 3\n");
printf("\n");
}
if (cin, nombres[3] > 999) {
printf("\nEn la posicion 4\n");
printf("\n");
}
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
int main()
{
int nombres[9];
cout << "Por favor ingrese la siguiente informacin de los Libros: \n";
volver:
system("cls");
for (int i = 0; i <= 9; i++)
{
}
printf("\nLa posicion de los numeros menos de 3 digitos es --------- \n");
if (cin, nombres[0] < 999) {
printf("\nEn la posicion 1\n");
printf("\n");
}
if (cin, nombres[1] < 999) {
printf("\nEn la posicion 2\n");
printf("\n");
}
if (cin, nombres[2] < 999) {
printf("\nEn la posicion 3\n");
printf("\n");
}
if (cin, nombres[3] < 999) {
printf("\nEn la posicion 4\n");
printf("\n");
}
int main()
{
int nombres[9], p;
cout << "Por favor ingrese la siguiente informacin de los Libros: \n";
volver:
system("cls");
for (int i = 0; i <= 9; i++)
{
}
{
printf("\nEl promedio es --------- \n");
system("pause");
goto volver;
}