daily pastebin goal
72%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int digits(int n) {
  2.     int d = 1;
  3.     int temp = n;
  4.     while ((temp /= 10) != 0) {
  5.         d++;
  6.     }
  7.     return d;
  8. }
  9.  
  10. int digitByIndex(int n, int i)
  11. {
  12.     int d = digits(n) - 1;
  13.     int temp = n;
  14.     while (d != i)
  15.     {
  16.         temp /= 10;
  17.         d--;
  18.     }
  19.     return temp % 10;
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top