Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
A+B ორობით სისტემაში
#include<bits/stdc++.h> using namespace std; string addBinary(string a, string b) { string result = ""; int s = 0; int i = a.size() - 1, j = b.size() - 1; while (i >= 0 || j >= 0 || s == 1) { s += ((i >= 0)? a[i] - '0': 0); s += ((j >= 0)? b[j] - '0': 0); result = char(s % 2 + '0') + result; s /= 2; i--; j--; } return result; } int main() { string a,b; cin >> a >> b; cout << addBinary(a, b) << endl; return 0; }
run
|
edit
|
history
|
help
0
CPPTemplate
Find value in sorted matrix
break.cpp
remove_if_30-Seconds-of-C++
Tower of hanoi
Microsoft - # of fragments (optimised)
CIDP2k19
Conjuntos - Contar caracteres únicos
TypeSizeTest
27