我心态崩了啊,感觉没问题为什么ac0啊,老哥们帮忙看看
还有要是笔试不过的话,我下次还能再参加吗
附代码
#include <bits/stdc++.h> using namespace std; bool check (int num) { if (num % 10 != 7) return false; num = num / 10; if (num % 2 == 0) return false; return true; } int main() { std::cout << "Hello, World!" << std::endl; int m, n; std::cin >> m >> n; if (m < 10 || n < 10) { cout << "[]"; return 0; } vector<vector<int>> res; int cnt = 0; int up = 0, down = m - up - 1, left = 0, right = n - left - 1; cout << "["; while (cnt < m * n) { for (int y = left; y <= right; y++) { cnt++; if (check(cnt)) { // cout << "[" << up << "," << y << "]";cout << ","; vector<int> tmp; tmp.emplace_back(up); tmp.emplace_back(y); res.emplace_back(tmp); } } if (++up > down) break; for (int x = up; x <= down; x++) { cnt++; if (check(cnt)) { // cout << "[" << x << "," << right << "]";cout << ","; vector<int> tmp; tmp.emplace_back(x); tmp.emplace_back(right); res.emplace_back(tmp); } } if (--right < left) break; for (int y = right; y >= left; y--) { cnt++; if (check(cnt)) { // cout << "[" << down << "," << y << "]";cout << ","; vector<int> tmp; tmp.emplace_back(down); tmp.emplace_back(y); res.emplace_back(tmp); } } if (--down < up) break; for (int x = down; x >= up; x--) { cnt++; if (check(cnt)) { // cout << "[" << x << "," << left << "]";cout << ","; vector<int> tmp; tmp.emplace_back(x); tmp.emplace_back(left); res.emplace_back(tmp); } } if (++left > right) break; } // cout << "]"; cout << "["; for (int i = 0; i < res.size() - 1; i++) { cout << "[" << res[i][0] << "," << res[i][1] << "],"; } cout << "[" << res.back()[0] << "," << res.back()[1] << "]]"; return 0; }
全部评论
(0) 回帖