手写int求助
  • 板块学术版
  • 楼主zxh_qwq
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/3/11 08:49
  • 上次更新2023/10/23 21:58:35
查看原帖
手写int求助
919709
zxh_qwq楼主2023/3/11 08:49
#include<bits/stdc++.h>
using namespace std;
enum tnum{
    a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=0//枚举类型
};
struct s_int{
    queue<tnum> q;
    void int_in(){
        char cc;
        while(q.size())q.pop();//清空
        while(cc!=' ')
        {
            cc=getchar();
            if(cc==' ')break;
            tnum t;
            switch(cc){//Switch
                case '0':t=j;break;
                case '1':t=a;break;
                case '2':t=b;break;
                case '3':t=c;break;
                case '4':t=d;break;
                case '5':t=e;break;
                case '6':t=f;break;
                case '7':t=g;break;
                case '8':t=h;break;
                case '9':t=i;break;
            }
            q.push(t);//插入
        }
    }
    void int_out(){
        while(q.size()){
            cout<<q.front();//循环输出
            q.pop();
        }
    }
};
int main(){
    s_int a;
    a.int_in();
    a.int_out();
    return 0;
}
2023/3/11 08:49
加载中...