Files
Borland-C/CPP/PROG5.CPP

96 lines
1.8 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Prog5
//
// Programadores:
//
// Juan L¢pez Fern ndez
// Moiss Virumbrales Cuenca
// DAI 1§A
//
// Pedir n£meros hasta que se introduzcan tres m£ltiplos de 7 (no
// necesariamente consecutivos) ¢ dos n£meros impares consecutivos.
// Imprimir el mayor valor introducido y su posici¢n.
#include <stdio.h>
#include <conio.h>
int mayor,posmayor,con,con7,conimpar,sw,num;
char pausa;
void main()
{
mayor=-32768;posmayor=0;con=0,con7=0;conimpar=0;sw=0;num=0;
clrscr();
gotoxy (20,16);
printf ("(Para finalizar introduzca");
gotoxy (20,17);
printf ("tres m£ltiplos de siete o");
gotoxy (20,18);
printf ("dos impares consecutivos)");
gotoxy (20,13);
printf (" Introduce un n£mero: ");
textcolor (4);
fflush(stdin);
cscanf ("%d",&num);
textcolor(7);
while (sw==0)
{
con++;
if (num %7==0)
{
con7++;
if (con7==3)
{
sw=1;
}
}
if (num %2!=0)
{
conimpar++;
if (conimpar==2)
{
sw=1;
}
}
else
{
conimpar=0;
}
if (num>mayor)
{
mayor=num; posmayor=con;
}
if (sw==0)
{
clrscr();
gotoxy (20,16);
printf ("(Para finalizar introduzca");
gotoxy (20,17);
printf ("tres m£ltiplos de siete o");
gotoxy (20,18);
printf ("dos impares consecutivos)");
gotoxy (20,13);
printf (" Introduce un n£mero: ");
textcolor (4);
fflush(stdin);
cscanf ("%d",&num);
textcolor(7);
}
}
clrscr();
gotoxy (20,12);
printf (" El mayor n£mero introducido es: ");
textcolor (14);
cprintf ("%d",mayor);
printf (".");
gotoxy (20,13);
printf (" Se ha introducido en la ");
cprintf ("%d¦",posmayor);
printf (" posici¢n.");
fflush (stdin);
scanf ("%c",&pausa);
}