Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.20 KB | None | 0 0
  1. int findDigit(int num, int nth) {
  2.     if (num < 0) {
  3.         num = abs(num);
  4.     }
  5.     if (nth < 0) {
  6.         return -1;
  7.     }
  8.     string number = to_string(num);
  9.     int index = number.length() - nth;
  10.     return number[0];
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement