我在做一个10进制转16进制的程序,程序如下,但是输出的结果是倒过来的~~~比如输入123,输出应为7B,但它输出的是B7, 我在for loop里面明明要它回倒了,为什么不执行呢???还是其他的原因,望哪为大哥帮忙看看~~
#include <iostream.h>
#include <stdlib.h>
void htio(int x, int y)
{
  int d,i=0;
  char Chars[] = {'A', 'B', 'C', 'D', 'E', 'F'};
  while( x != 0 )
  {
    d = x % 16;
    x = x / 16;
    if ( d >=10)
      cout << Chars[d-10];
      else
        cout << d;
  }
  for (d = i - 1; d >= 0; d--)
  {
    cout << Chars[d];
  }
}
int main()
{
      int a;
      cout << "please enter a positive number  ";
      cin >> a;
      cout << "\n";
      htio(a, 16);
      system("PAUSE");
      return 0;
}



 
											





 
	    

 
	