本文介绍了c编程:将非十进制数字系统转换为十进制的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void main()
{
 long n,dec,mult,r,base;
 clrscr();
 printf("\n Enter a base : ");
 scanf("%ld",&base);
 printf("\n Enter a number :");
 scanf("%ld",&n);
 dec = 0;
 mult=1;
 printf("\n Decimal equivalent of base %ld number %ld is ",base,n);
 while ( n != 0 )
 {
  r = n % 10;
  n /= 10;
  r = r * mult;
  dec = dec + r;
  mult *= base;
 }
 printf("%ld",dec);}


此程序将以2、8和16为基数的任何数字系统的整数部分转换为十进制.请告诉我命令shld b给定2还要计算小数部分.我急需它帮助.


this program converts the integer part of any number system of base 2, 8 &16 to decimal. please tell me wht command shld b given 2 calculate the fractional part also. i need it urgently plz help.

推荐答案

0
4 / 8  // .4
4 /64  // . 04


这篇关于c编程:将非十进制数字系统转换为十进制的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 03:31