Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Adding LargeNumbers via Stacks & Strings

$
0
0
So Im trying to take a number from a string and put it onto a stack.

string number1 = 10000000 or something like that and then i wanted to do the same thing and add them together, but I have to add them together 1 digit at a time like you would if you were doing normal addition.
100000
+100011

If you know what I mean. I am currently stuck and I was hoping someone be able to help.

class bigNumbers {

public:

	void Number1(const string& input);
	void Number2(const string& input);
	int Result();

private:

	stack<int> stack1;
	stack<int> stack2;

};

void bigNumbers::Number1(const string& input){
	int temp = 0;

	for(int i = 0; i > sizeof(input); i++) {
		temp = 48 - input[i];
		cout << temp;
		stack1.push(temp);
			
	}
}



When I debug the code it skips over the for loop

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>