Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getReverseOddDigit(int a){
- int count = 1, count1 = 0, count2 = 0;
- int b1 = 0, b2 = 0, b = 0, tempB;
- bool isNegative = false;
- if(a < 0) {
- isNegative = true;
- a = -a;
- }
- do {
- if(count % 2){
- b1 += (a % 10) * pow(10, count1);
- count1++;
- } else {
- b2 += (a % 10) * pow(10, count2);
- count2++;
- }
- count++;
- a /= 10;
- } while(a > 10);
- if(count % 2){
- b1 += (a % 10) * pow(10, count1);
- tempB = b1;
- } else {
- b2 += (a % 10) * pow(10, count2);
- tempB = b2;
- }
- while(tempB)
- {
- b = b*10 + tempB%10;
- tempB /= 10;
- }
- return isNegative ? -b : b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement