1 #include<iostream> 2 #include<vector> 3 4 using namespace std; 5 6 int main() 7 { 8 vector<int> v; 9 vector<int> result; 10 int n; 11 int a, b; 12 while (cin >> n) 13 v.push_back(n); 14 for (auto iter = v.begin(); iter != v.end(); iter += 2) 15 { 16 a = *iter; 17 b = *(iter + 1); 18 if (a == 0 && b == 0) 19 { 20 result.push_back(0); 21 result.push_back(0); 22 } 23 if (a*b != 0) 24 { 25 result.push_back(a*b); 26 result.push_back(b - 1); 27 } 28 } 29 bool flag = 0; 30 if (!result.empty()) 31 for (auto c : result) 32 { 33 cout << (flag == 0 ? "" : " ") << c; 34 flag = 1; 35 } 36 else 37 cout << 0 << " " << 0; 38 39 return 0; 40 }
原文:https://www.cnblogs.com/Huayra/p/12172232.html