第一题统计和为0的个数,没有去重 #include <iostream> #include <vector> #include <set> #include <map> #include <bitset> #include <iomanip> #include <algorithm> #include <functional> #include <queue> using namespace std; int main() { vector<int>a; int tmp; char ch; while ((cin >> tmp).get(ch)) { a.push_back(tmp); if (ch == '\n') break; } int n = a.size(); vector<int>b(n, 0); int cnt = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (b[i] == 0 && b[j] == 0) { if (a[i] + a[j] == 0) { cnt++; b[i] = 1; b[j] = 1; } } } } cout << cnt << endl; system("pause"); return 0; }