Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/02/2013, 02:09
Avatar de pepitogrillo13051993
pepitogrillo13051993
 
Fecha de Ingreso: febrero-2013
Mensajes: 20
Antigüedad: 11 años, 3 meses
Puntos: 0
Información Programa básico c/c++ (tutorial 4.5)

Programa que recibe por teclado 3 números enteros y positivos e imprime todos los valores numéricos enteros que podemos encontrar entre los 3 valores.

#include <iostream>
#include <stdio.h> /* printf y scanf */
#include <conio.h> /* flush(stdin), getche, getch */
#include <string.h> /* strcopy(), gets(), strcat() */
#include <stdlib.h> /* Lo uso para que funcione el system("cls") */

using namespace std;

int main()
{

int num1, num2, num3, major, mig, menor, result=0;
char opcio[3];

system("title=Exercici 5"); /* Este es el titulo de la ventana */

do{
do {
printf("Escriu el primer nombre sencer y positiu: \n");
scanf("%d", &num1);
system("cls");
printf("Escriu el segon nombre sencer y positiu: \n");
scanf("%d", &num2);
system("cls");
printf("Escriu el tercer nombre sencer y positiu: \n");
scanf("%d", &num3);
system("cls");
} while (num1<0 || num2<0 || num3<0);

if (num1>num2){
if (num1>num3){
major=num1;
if(num2>num3){
mig=num2;
menor=num3;
}
else{
mig=num3;
menor=num2;
}
}
else{
major=num3;
mig=num1;
menor=num2;
}
}
else{
if(num2>num3){
major=num2;
if(num1>num3){
mig=num1;
menor=num3;
}
else{
mig=num3;
menor=num1;
}
}
else{
major=num3;
mig=num2;
menor=num1;
}
}

result=menor+1;

while (major>result){
if (result!=mig)
printf("%d \n", result);
result=result+1;
}

printf ("\n\nEscriu si para tornar a comenzar, y qualsevol altre paraula per sortir: ");
scanf("%s", &opcio);
system("cls");
} while (!strcmp(opcio, "si"));

return 0;
}