Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int findDigit(int num, int nth) {
- if (num < 0) {
- num = abs(num);
- }
- if (nth < 0) {
- return -1;
- }
- string number = to_string(num);
- int index = number.length() - nth;
- return number[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement