【选择题】进制转换

【选择题】进制转换


1、题目:有以下程序,程序运行后的输出结果是 ( C )

#include <iostream>
#include <stdio.h>
using namespace std;
int main ()
{
    
    
    int m = 0123, n = 123;
    printf("%o %o",m,n);
    return 0;
}

   A: 0123 0173
   B: 0123 173
   C: 123 173
   D: 173 173

   【分析】:%o表示以八进制格式输出。

image-20210311114836185

  因为m=0123,前缀是0,表示的就是八进制数,所以输出的m的值是123。n=123,表示的是十进制整数,输出要以八进制格式输出,所以是173。

八进制是按照二进制的每3位计算的

十六进制是按照二进制的每4位计算的


猜你喜欢

转载自blog.csdn.net/Sunnyside_/article/details/114436501