永发信息网

C++打印8/16进制有哪些方法?

答案:3  悬赏:0  手机版
解决时间 2021-03-09 08:09
  • 提问者网友:愿为果
  • 2021-03-08 12:12
有几种方式啊, 望列举
最佳答案
  • 五星知识达人网友:野味小生
  • 2021-03-08 12:57
#include "include\stdio.h"int main()
{
int i = 10;
printf("8 = %o\n16 = %x\n",i,i);
return 0;
}//一种方法,也是最简单的了,还有就是自己编写算法等。
全部回答
  • 1楼网友:酒者煙囻
  • 2021-03-08 13:56
在百度搜索C++输入输出流 大把的输出方法
  • 2楼网友:千夜
  • 2021-03-08 13:29
你的程序没错,只是没考虑用户输入小写a-f字符时的情况,我帮你加上了,你看看吧. 完整的程序如下:(改动的地方见注释) #include #include #include #include using namespace std; void convert(string *a,int n); int main() {     int times,i;     string temp;     cin>>times;     string* a = new string[times];     for(i=0;i>temp;         a[i] = temp;     }     //cout<='0' && c<='9')     {         return c-48;     }     else if(c>='a' && c<='f')     {         return c-55;     }  else if(c>='a' && c<='f')//这里加一句判断  {   return c-87;//这里加一句返回值  } } void convert(string *a,int n) {     int i,j;     stack constack;  for(i=0;i=0;j--)         {             value += pow(16.0,ex) * chartovalue(a[i][j]);//这里pow(16,ex)改成pow(16.0,ex)             ex++;         }         if(value == 0)         {             cout<<0<
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯