做这种加法,乘法的题一定要先进行反转,再进行操作。
因为要进位一定要反转,一下原数组,然后进行进位的操作,这里要注意下,我们进行完进位的操作后,还要判断t是否大于0,如果大于0 还要再加入到数组中,最后再反转下数组。
class Solution {
public:
vector plusOne(vector& d) {
reverse(d.begin(),d.end());
int t=1;
for(int i=0;i

做这种加法,乘法的题一定要先进行反转,再进行操作。
因为要进位一定要反转,一下原数组,然后进行进位的操作,这里要注意下,我们进行完进位的操作后,还要判断t是否大于0,如果大于0 还要再加入到数组中,最后再反转下数组。
class Solution {
public:
vector plusOne(vector& d) {
reverse(d.begin(),d.end());
int t=1;
for(int i=0;i