Skip to content

Instantly share code, notes, and snippets.

@pureexe
Created October 23, 2012 05:26
Show Gist options
  • Select an option

  • Save pureexe/3936869 to your computer and use it in GitHub Desktop.

Select an option

Save pureexe/3936869 to your computer and use it in GitHub Desktop.
กลับค่าตัวเลขแล้ว return int ที่กลับค่า
#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