Está en la página 1de 5

#include <stdio.

h>
#include <iostream.h>
#include <conio.h>
#include <math.h>

char i,r='s';
float raro(),num,k;
int m=1,a,b,c=1,cont,punto,negativo,p=2;

float raro()
{
while(i!='*')
{
a=a+1;
if(i>='0' && i<='9')
{
num=i-48;
k=k+num;
k=10*k;
cont=10*cont;
}
/*if(i>'A')
{
printf("letra\n\n");
}*/

if(i=='.')
{
cont=10;
punto=punto+1;
}

if(i=='-')
{
m=-1;
negativo=negativo+1;
c=c+1;
}
//printf("\ningrese cualquier caracter\n");
scanf("%c",&i);

}
if(c==1 || c==2)
{
/*if(cont==0)
{
printf("\n\tse reconocio el numero\t%f",m*k/10);
}*/

if(cont!=0 && punto==1 && negativo<=1)


{
if(a>=4 && negativo==1)
{

printf("el signo (-) no esta en su lugar\n");


}else {printf("\n\tse reconocio el numero\t%f",(m*k)/cont);}
}

if(cont==0 && negativo<=1)


{
if(a>=4 && negativo==1)
{
printf("el signo (-) no esta en su lugar\n");
}else {printf("\n\tse reconocio el numero\t%f",(m*k)/10.00);}
}

if(punto>1)
{
printf("ingreso mas de un '.'");
}

if(negativo>1)
{
printf("ingreso mas de un '-'");
}
}

else
{
printf("\ntenga cuidado con el numero de signos (-) que ingresa\n");
}

return (k);

main()
{

while(p>0)
{
if(r=='s')
{
clrscr();
printf("\n\n\t\t BIENVENIDO AL RECONOCEDOR DE NUMEROS\n");

printf("\t\t=====================================================\n");
printf("\n\tPUEDE INGRESAR CUALQUIER CARACTER\n\tEL SIGNO (-) Y EL (.)
PONDRAN INGRESARSE SOLO UNA VEZ\n");
printf("\n\t\tEL RECONOCIMIENTO EMPEZARA CUANDO USTED PRESIONE
(*)\n");
printf("\ningrese cualquier caracter\n");
k=0;
cont=0;
c=1;
a=0;
negativo=0;
punto=0;
m=1;

scanf("%c",&i);
raro();
printf("\n\n\n\tsi desea encontrar la distancia entre dos puntos diferentes
\n\tpresione s\n\n\tcaso contrario\n\tpresione n\n\t\t");
}
scanf("%c",&r);

if(r=='n')
{
p=-2;
printf("\n\t\tGRACIAS");
}
}
}

También podría gustarte