Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int intreg(double x)
- {
- int y = (int)x;
- return (x == y);
- }
- int cate_cifre(long long x)
- {
- int ct=0;
- while(x)
- {
- x/=10;
- ct++;
- }
- return ct;
- }
- int main()
- {
- double x;
- scanf("%lf",&x);
- int ctmax=0;
- double max;
- int ok=1;
- while(x && ok)
- {
- double y=x;
- int ct=0;
- if(intreg(x))
- {
- ok=0;
- break;
- }
- while(!intreg(y) && cate_cifre(y)<15)
- {
- y=y*10;
- ct++;
- }
- long long z=y;
- while(z%10==0)
- {
- z/=10;
- ct--;
- }
- if(ct>=ctmax)
- {
- ctmax=ct;
- max=x;
- }
- scanf("%lf",&x);
- }
- if(ok==1)
- printf("%lf",max);
- else
- printf("Date de intrare invalide");
- return 0;
- }
Add Comment
Please, Sign In to add comment