|
这个程序能把十进制转化为8进制和16进制,至于转化回十进制,和十进制与二进制的互相转化还没有写,以后会把功能补全的(^_^)
以下是代码
#include <stdio.h>
#include <windows.h>
int main()
{
while(1)
{
int choose, converted, i;
char yesorno;
printf("This Program can Change Decimal into Octal or Hexadecimal.\n");
printf("Which Do You Want?Please Enter The Number.\n\n");
printf("1.Change Decimal into Octal.\n");
printf("2.Change Decimal into Hexadecimal.\n");
printf("3.Change Decimal into Octal and Hexadecimal.\n\n");
scanf("%d",&choose);
if(choose!=1&&choose!=2&&choose!=3)
{
printf("\nInput Error!Please Input Again!\n");
Sleep(3000);
system("cls");
main();
}
printf("\nPlease Enter The Converted Number.\n\n");
scanf("%d",&converted);
if(choose==1)
{
printf("\n%d(Decimal) Change into %o(Octal).\n",converted,converted);
}
if(choose==2)
{
printf("\n%d(Decimal) Change into %X(Hexadecimal).\n",converted,converted);
}
if(choose==3)
{
printf("\n%d(Decimal) Change into %o(Octal) and %X(Hexadecimal).\n",converted,converted,converted);
}
for(i=10;i>=0;i--)
{
printf("Clear the Screen after %d Second(s)\n\n",i);
Sleep(1000);
}
system("cls");
}
}
[/mw_shl_code] |
|