这个代码是哪错了呢?加上标准库头文件还是不行
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
using namespace std;
#include<stack>
class Solution {
public:
ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) {
//先建立两个栈,把料表数据放进去,达到正序的效果
stack s1,s2;
while(s1.next){
s1.push(*l1++);
}
while(s2.next){
s2.push(*l2++);
}
int n = s1.size();
int m = s2.size();
//下面是为了把栈中数据转化为整数
int tmp1 = s1.pop()*10;
for(int i = 1;i < n;i++){
int number = (tmp1 +s1.pop())*10;
tmp1 = number;
}
int tmp2 = s2.pop()*10;
for(int i = 1;i < n;i++){
int number = (tmp2 +s2.pop())*10;
tmp2 = number;
}
int numbers = tmp1 +tmp2;
return numbers;
}
};