瑞星卡卡安全论坛技术交流区系统软件 [江湖救急]编C语音程序!!!!!

1   1  /  1  页   跳转

[江湖救急]编C语音程序!!!!!

[江湖救急]编C语音程序!!!!!


把任意进制间的转换算法  用C语言编出来!!!!!

也就是编一个C语言程序  用来进行任意进制间的转换
最后编辑2007-07-14 22:04:30
分享到:
gototop
 

void main()
{
        int a,b;
        char jieguo[8]="";
        printf("请输入原数:");
        scanf("%d",&a);

        printf("请输入要转换成多少进制:");
        scanf("%d",&b);
        itoa( a, jieguo, b );
        printf("%s",jieguo);
}
gototop
 

这么短?? - -%
gototop
 

嘻嘻^-^
gototop
 

好象只能把十进制转换成其他进制呢`  不能互相转换呀``
gototop
 

实在不行自己写方法,用碾转相除 的方法
gototop
 

#include "stdio.h"
main(){
char ch;
int count=1;
loop:
printf("\n");
printf("Please input any key you want to know!\n");
ch=getch();
printf("The NO.%d  key you entered \n\n",count);



if(ch==32)
printf("                    in ASCII :  SPACE\n");
else if(ch==8)
printf("                    in ASCII :  BACK SPACE\n");
else if(ch==13)
printf("                    in ASCII :  ENTER\n");
else if(ch==9)
printf("                    in ASCII :  TAB\n");
else
printf("                    in ASCII :  %c\n",ch);
printf("                    in HEX  :  %x\n",ch);
printf("                    in DEC  :  %d\n",ch);
printf("                    in OCX  :  %o\n",ch);
binary(ch);
printf("\n");
printf("Quit at anytime by pressing CTRL-N!\nLet's go on?\n");
if(getch()==14) exit(0);
count++;
goto loop;
}
char cc;
int binary(cc)
{
int var[16];
int i,j=0;
while(cc!=0)
{
var[j++]=cc%2;
cc/=2;
}
printf("                    in BINARY:  ");
for(i=j-1;i>=0;--i) printf("%d",var);
printf("\n");
}
gototop
 

都是历害中人哈PF~~~
gototop
 

C语言好学吗??
gototop
 
1   1  /  1  页   跳转
页面顶部
Powered by Discuz!NT