网易雷火笔试,大家情况怎么样
前两道AC,第三道70%,第四道瞎写8%,第五道汇编压根不会
第一题
#include <bits/stdc++.h>using namespace std;struct window{int x;int y;int w;int h;int id;window(int x, int y, int w, int h, int id) : x(x), y(y), w(w), h(h), id(id) {}};bool inside(int px, int py, window *win){if ((px >= win->x) && (px <= (win->x + win->w)) && (py >= win->y) && (py <= (win->y + win->h)))return true;elsereturn false;}int main(){int n, m;cin >> n >> m;list<window *> l;for (int i = 0; i < n; i++){int x, y, w, h;cin >> x >> y >> w >> h;l.push_front(new window(x, y, w, h, i + 1));}for (int i = 0; i < m; i++){bool isClick = false; // 是否点到了int px, py;cin >> px >> py;for (auto it = l.begin(); it != l.end(); it++) // 自顶向下判断点击{if (inside(px, py, *it)) // 如果点到了这个窗口{isClick = true;cout << (*it)->id << endl;if (it != l.begin()) // 如果不是最顶的窗口{// cout << "bushizuidin" << endl;window *wptr = *it;l.erase(it);l.push_front(wptr);}break;}}if (!isClick)cout << -1 << endl;}return 0;}
第二题
#include <bits/stdc++.h>using namespace std;int r = 0, c = 0;bool check(int p, int q, vector<int> &nums){for (int i = 0; i < nums.size(); i++){if (nums[i] == p && nums[nums.size() - i - 1]==q){r = log(nums.size()) / log(2) + 1;c = i + 1;return true;}}return false;}int main(){int p, q;cin >> p >> q;vector<int> nums;list<int> temp;temp.push_back(0);temp.push_back(1);for (int i = 0; i < 12; i++){nums.clear();for (auto it = temp.begin(); it != temp.end(); it++){int n1 = *it;int n2;if ((++it) != temp.end()){n2 = *it;}else{break;}int n = n1 + n2;nums.push_back(n);it = temp.insert(it, n);}// for (auto c : nums)// {// cout << c << " ";// }// cout << endl;if (check(p, q, nums)){cout << r << " " << c << endl;return 0;}}return 0;}
第三题(70%)
#include <bits/stdc++.h>using namespace std;int x = 0, y = 0;int lasty = 0;int maxH = 0;bool test = false;int w, xe, ye, xc, yc, px, py;inline void enter(){if (test)cout << "换行一次" << endl;x = 0;if (y != 0)y += py;y += (maxH == 0 ? ye : maxH);maxH = 0;}inline void add(int inx, int iny){if (x + px + inx >= w){enter();add(inx, iny);}else{maxH = max(maxH, iny);if (x != 0)x += px;x += inx;}}int main(){cin >> w >> xe >> ye >> xc >> yc >> px >> py;vector<vector<int>> image(20, vector<int>(2));for (int i = 0; i < 20; i++){int inputx, inputy;cin >> inputx >> inputy;image[i][0] = inputx;image[i][1] = inputy;}string input;cin >> input;string str;for (int i = 0; i < input.size(); i += 2){stringstream ss;int h;ss << input.substr(i, 2);ss >> hex >> h;str.push_back((char)h);}if (test)std::cout << endl<< str << endl;for (int i = 0; i < str.size(); i++){if (str[i] == '#'){if (i == str.size() - 1) // 这是最后一个字符{if (test)cout << "插入英文" << str[i] << endl;add(xe, ye); // 插入英文字符continue;}else if (str[i + 1] == '0' || (str[i + 1] <= '9' && str[i + 1] >= '2')) // #后面跟着不为1的一个数{stringstream ss;ss << str[i + 1];int n;ss >> n;add(image[n][0], image[n][1]); // 插入表情i++;continue;}else if (str[i + 1] == '1') // 后面跟着1{if (i + 2 >= str.size()){add(image[1][0], image[1][1]);if (test)cout << "插入表情" << 1 << endl;i++;continue;}else if (str[i + 2] <= '9' && str[i + 2] >= '0'){stringstream ss;ss << '1' << str[i + 2];int n;ss >> n;if (test)cout << "插入表情" << n << endl;add(image[n][0], image[n][1]);i += 2;continue;}else{if (test)cout << "插入表情" << 1 << endl;add(image[1][0], image[1][1]);i++;continue;}}else if (str[i + 1] == 'r') // 换行{enter();i++;}else if (str[i + 1] == '#') // 输出#{if (test)cout << "插入英文"<< "#" << endl;add(xe, ye);i++;continue;}else // 原样输出{if (test)cout << "插入英文" << str[i] << endl;add(xe, ye);}}else if (str[i] >= 0 && str[i] <= 127){if (test)cout << "插入英文" << str[i] << endl;add(xe, ye);}else{stringstream ss;ss << str.substr(i, 3);if (test)cout << "插入中文 " << ss.str() << x << " " << y << endl;add(xc, yc);i += 2;}}if (test)cout << "maxH:" << maxH << endl;y += py + maxH;cout << x - 1 << " " << y - 1 << endl;return 0;}
#网易##笔试题目#