Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // INCREMENTO
- void incBin(string *bin, int indice){
- int j;
- for(int i = indice; i >=0; i--){
- if((*bin).at(i) == '0'){
- (*bin).at(i) = '1';
- j = i;
- break;
- }
- }
- j++;
- for(j ; j <= indice; j++){
- (*bin).at(j) = '0';
- }
- }
- // SOMA USANDO O INCREMENTO
- void soma(string *bin, string bin2){
- int j = 0;
- for(int i = bin2.size()-1; i >= 0; i--){
- if(bin2.at(i) == '1')
- incBin(bin, (*bin).size()-1 -j);
- j++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement