diff --git a/README.md b/README.md index cfe1150..5b23c02 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,61 @@ -# 1 + #include +#import +#define maxsize 100 +typedef struct +{ + int *base; + int *top; + int stacksize; +} sqstack; + +void initstack(sqstack &s) +{ + s.base = malloc(maxsize*sizeof(int)); + if(!s.base)exit; + s.top=s.base; + s.stacksize=maxsize; +} + +void push(sqstack &s,int e){ + if(s.top-s.base==s.stacksize)return; + *s.top++=e; + return; +} + +void pop(sqstack &s,int &e){ + if(s.top==s.base)return; + e=*--s.top; + return; +} + +void zhuanhuan(sqstack &a,int e){ + int temp; + while(e!=0){ + temp=e%16; + push(a,temp) + e=e/16; + } + string str; + while(s.top==s.base){ + int n=0; + pop(a,n) + if(n>=10){ + str = char('A'-10+n)+str; + } + else{ + str=char('0'+n)+str + } + } + cout << "转化后的十六进制数如下" << endl; +} + +int main(){ + int a=0; + sqstack* y=(sqstack*)malloc(sizeof(sqstack)); + initstack(y); + cout << "请输入想要转化的十进制数字" << endl; + cin >> a; + zhuanhuan(y,a) + } +} \ No newline at end of file