悬五关
  • 板块学术版
  • 楼主UKE_bound
  • 当前回复1
  • 已保存回复1
  • 发布时间2024/6/11 17:24
  • 上次更新2024/6/11 20:35:12
查看原帖
悬五关
1073741
UKE_bound楼主2024/6/11 17:24
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
using namespace std;
class bigint{
	public:
		bigint(string t="0"){
			for(int i=t.size()-1;i>-1;i--){
				a.push_back(a[i]-'0');
			}
			l=t.size();
		}
		bigint(int g){
			stringstream s;
			s<<g;
			string t;
			s>>t;
			for(int i=t.size()-1;i>-1;i--){
				a.push_back(a[i]-'0');
			}
			l=t.size();
		}
		int& operator[](int x){
			return a[x];
		}
		const int& operator[](int x)const{
			return a[x];
		}
		const int& getl(void)const{
			return l;
		}
	private:
		vector<int> a;
		int l;
};
istream& operator>>(istream& in,bigint& b){
	string t;
	in>>t;
	b=bigint(t);
	return in; 
}
ostream& operator<<(ostream& out,const bigint& b){
	for(int i=b.getl()-1;i>-1;i--){
		out<<b[i];
	}
	out<<endl;
	return out;
}
int main(){ 
    bigint a();
    cin>>a;
    cout<<a;
	return 0; 
}

这是怎么回事?

2024/6/11 17:24
加载中...