Skip navigation.

滩头一粒沙,世间一刹那

人生何其短!

编程实现将任意的十进制整数转换成R进制数(R在2-16之间)。

#include<stdio.h>
#include<conio.h>
int main(void)
{
int n,R,i=0,a[16]={0};
char str[17]="0123456789ABCDEF";
printf("please input an integer number:\n");
scanf("%d",&n);
printf("please input R:\n");
scanf("%d",&R);
if(n<0)
{
printf("%c",'-');
n=-n;
}
while(n!=0)
{
a[i++]=n%R;
n=n/R;
}
while(i-->0)
printf("%c",str[a]);
getche();
}

金子与粪土(Gold or Turd)mount命令的使用方法

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies