fork download
  1. #include <stdio.h>
  2.  
  3. char *itoa(int ival, char *str, int radix)
  4. {
  5. static const char table[] = "01";
  6. char *head = str;
  7. char *tail = str;
  8. char tmp;
  9.  
  10. if (ival == 0) {
  11. *tail++ = '0';
  12. } else {
  13. for (; ival; ival /= radix) {
  14. *tail++ = table[ival % radix];
  15. }
  16. }
  17. *tail = '\0';
  18. for (tail--; head < tail; head++, tail--) {
  19. tmp = *head;
  20. *head = *tail;
  21. *tail = tmp;
  22. }
  23. return str;
  24. }
  25.  
  26. int main()
  27. {
  28. char s[33];
  29. int A, B;
  30.  
  31. scanf("%d", &A);
  32. B = A << 3;
  33. itoa(A, s, 2);
  34. printf("A=%d %s\n", A, s);
  35. itoa(B, s, 2);
  36. printf("B=%d %s\n", B, s);
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0.02s 1680KB
stdin
10
stdout
A=10 1010
B=80 1010000