Created
October 23, 2012 05:26
-
-
Save pureexe/3936869 to your computer and use it in GitHub Desktop.
กลับค่าตัวเลขแล้ว return int ที่กลับค่า
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef INTREV_H_INCLUDED | |
| #define INTREV_H_INCLUDED | |
| int pow_int(int base,int n) | |
| { | |
| int ans=1,i; | |
| for(i=1;i<=n;i++) | |
| ans*=base; | |
| return ans; | |
| } | |
| int intrev(int in) | |
| { | |
| int u[100],ct=0,i,ans=0; | |
| while(in>=1) | |
| { | |
| u[ct++]=in%10; | |
| in/=10; | |
| } | |
| for(i=0;i<ct;i++) | |
| { | |
| ans+=u[i]*pow_int(10,ct-i-1); | |
| } | |
| return ans; | |
| } | |
| #endif // INTREV_H_INCLUDED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment