|
|
back to boardruntime error (access violation) visual c++ #include <iostream> #include <stack> using namespace std; int main() { unsigned short n1, n2, n3; int a, n=0; stack<int> group1; cin >> n1; for (int i = 0; i <n1; i++) { scanf_s("%d", &a); group1.push(a); } stack<int> group2; cin >> n2; for (int i = 0; i < n2; i++) { scanf_s("%d", &a); group2.push(a); } stack<int> group3; cin >> n3; for (int i = 0; i < n3; i++) { scanf_s("%d", &a); group3.push(a); } while (!group1.empty()) { if (group1.top() == group2.top()) { if (group1.top() == group3.top()) { n++; group1.pop(); group2.pop(); group3.pop(); if ((group1.empty()) || group2.empty() || group3.empty()) break; } else if (group1.top() > group3.top()) { group1.pop(); group2.pop(); if (group1.empty() || group2.empty()) break; } else group3.pop(); } if (group1.top() > group2.top())group1.pop(); if (group1.empty()) break; if (group1.top() < group2.top())group2.pop(); if (group2.empty()) break; } cout << n;
} what's wrong? Re: runtime error (access violation) visual c++ after else group3.pop(); if (group3.empty()) break; accapte |
|
|