?? 進(jìn)制轉(zhuǎn)換.cpp
字號(hào):
// 進(jìn)制轉(zhuǎn)換.cpp : Defines the entry point for the console application.
//
#include "stdio.h"
#include "stdlib.h"
#include "iomanip.h"
#include "seqstack.h"
/*#define STACK_INIT_SIZE 100
#define STACKINCREMENT 10
typedef int SElemType;
typedef struct
{
SElemType *base;
SElemType *top;
int stacksize;
}SqStack;
void InitStack (SqStack &S)
{
S.base=new SqStack;
if(!S.base)
{
printf("OVERFLOW");
exit(1);
}
S.top=S.base;
S.stacksize=STACK_INIT_SIZE;
//return ok;
}
*/
void main()
{
seqstack S;
int n,x,e;
do
{
printf("請(qǐng)輸入您想要轉(zhuǎn)換的進(jìn)制:");
scanf("%d",&x);
if (x>16||x<2)
printf("進(jìn)制數(shù)超范圍! \n");
}while(x<2||x>16);
InitStack(S);
printf("請(qǐng)輸入您想要轉(zhuǎn)換的數(shù):");
scanf("%d",&n);
printf("十進(jìn)制數(shù) %d 轉(zhuǎn)換成 %d 進(jìn)制數(shù)為:",n,x);
while (n)
{
Push(S,n%x);
n=n/x;
}
n=0;
while(!Empty(S))
{
e=Pop(S);
if(e<10)
{printf("%d",e);n++;}
else
{printf("%c",e+55);n++;}
if(n>2)
{n=0;printf(" ");}
}
//printf("Hello World!\n");
//return 0;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -