返回列表 發帖
本帖最後由 李穎俊 於 2024-11-30 15:04 編輯
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. string s1,s2;
  4. int a,b;
  5. int main(){
  6.     getline(cin,s1);
  7.     a=stoi(s1,nullptr,2);
  8.     getline(cin,s2);
  9.     b=stoi(s2,nullptr,2);
  10.     cout<<a<<" + "<<b<<" = "<<a+b<<endl;
  11.     if(a+b>255)
  12.         cout<<"11111111"<<endl;
  13.     else
  14.         cout<<bitset<8>(a+b);
  15. }
複製代碼

TOP

返回列表