- #include<bits/stdc++.h>
- using namespace std;
- string a,b;
- int main()
- {
- cin>>a>>b;
- cout<<stoi(a,nullptr,2)<<" + "<<stoi(b,nullptr,2)<<" = "<<stoi(a,nullptr,2)+stoi(b,nullptr,2)<<endl;
- if(stoi(a,nullptr,2)+stoi(b,nullptr,2)>255)
- {
- cout<<"11111111"<<endl;
- return 0;
- }
- bitset<8> bit(stoi(a,nullptr,2)+stoi(b,nullptr,2));
- cout<<bit;
- return 0;
- }
複製代碼 |