---
# System prepended metadata

title: Question 415. Add Strings
tags: [leetcode]

---

###### tags: `leetcode`
# Question 415. Add Strings
### Description:

### Solution:

### AC code
```cpp=
#include "stdlib.h"
class Solution {
public:
    string addStrings(string num1, string num2) {
        int len1 = num1.length();int i = len1-1;
        int len2 = num2.length();int j = len2-1;
        int a = 0;int b = 0;char tmp;int remain = 0;
        string ret = "";
        for(i,j ; i >=0 || j >=0 ; i--, j--){
            if(i<0)
                a = 0;
            else
                a = num1[i]-'0';
            if(j<0)
                b = 0;
            else
                b = num2[j]-'0';
            tmp = a+b+remain;
            remain = 0;
            if(tmp>=10){
                remain = tmp/10;
            }
            tmp = int(tmp)%10+'0';
            ret = tmp+ret;
        }
        if(remain!=0){
            tmp = remain+'0';
            ret = tmp+ret;            
        }
        return ret;
    }
};
```