登 录
#include <iostream> #include <math.h> #include <stdlib.h> #include <string> #include <assert.h> #include <algorithm> using namespace std; int main() { int ten; scanf("%u", &ten); //是用%u,而不是%ud int cnt = 0; char eight[10] = {0}; while(ten) { eight[cnt++] = ten % 8 + '0'; //注意要 加'0' ten = ten / 8; } int len = strlen(eight); for(int j = len-1; j >= 0; j-- ) printf("%c", eight[j]); //以%c输出,若上 面是不加‘’,这个地方以%d输出,则输入没结果。 return 0; }
抱歉!评论已关闭.