8进制
八进制
http://www.nowcoder.com/questionTerminal/eda051c1effc4dffa630bc8507f0c5f7
#include #include #include using namespace std; char IntToChar(int target) { if (target < 10) { return target + '0'; } else { return target - 10 + 'A'; } } void Convert(int number, int x) { vectorint> answer; if (number == 0) { answer.push_back('0'); } else { while (number != 0){ answer.push_back(IntToChar(number % x)); number /= x; } } for (int i = answer.size() - 1; i >= 0; --i) { printf("%c", answer[i]); } printf("\n"); } int main() { int n; while (scanf("%d", &n) != EOF) { Convert(n, 8); } return 0; }