Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double Average(long long n)
- {
- long long r, q = n, s = 0, tot = 0;
- while(q > 0) {
- r = q % 10;
- s += r;
- q /= 10;
- tot++;
- }
- return (double)s / (double)tot;
- }
- int main()
- {
- long long x; // as x <= 10^19
- scanf("%lld", &x);
- double avg = Average(x);
- printf("%lf\n", avg);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment