依图8.28笔试

第一题:
#include <iostream>
using namespace std;
int main(){
    int T;
    cin >> T;

    for(int t = 0; t < T; t++){
        cout << "Case #" << t+1 << ":" << endl;
        int n, m;
        cin >> n >> m;
        int direction = 0;
        int cur_x = 0, cur_y = 0;
        for(int i = 0; i < m; i++){
            char op;
            int step;
            cin >> op;
            if(op == 'L'){
                direction = (direction + 3) % 4;
            }
            if(op == 'R'){
                direction = (direction + 1) % 4;
            }
            if(op == 'G'){
                cin >> step;
                if(direction == 0){
                    cur_y = cur_y - step >= 0? cur_y - step:0;
                }
                if(direction == 1){
                    cur_x = cur_x + step <= n - 1? cur_x + step: n - 1;
                }
                if(direction == 2){
                    cur_y = cur_y + step <= n - 1? cur_y + step: n - 1;
                }
                if(direction == 3){
                    cur_x = cur_x - step >= 0? cur_x-step:0;
                }
            }
            if(op == 'P'){
                cout << cur_x << " " << cur_y << endl;
            }
        }
    }
    return 0;
}
AC
第二题:
没记录
第三题:
没记录
第四题:
没记录
#笔试题型#
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 11:16
点赞 评论 收藏
分享
06-17 00:26
门头沟学院 Java
程序员小白条:建议换下项目,智能 AI 旅游推荐平台:https://github.com/luoye6/vue3_tourism_frontend 智能 AI 校园二手交易平台:https://github.com/luoye6/vue3_trade_frontend GPT 智能图书馆:https://github.com/luoye6/Vue_BookManageSystem 选项目要选自己能掌握的,然后最好能自己拓展的,分布式这种尽量别去写,不然你只能背八股文了,另外实习的话要多投,尤其是学历不利的情况下,多找几段实习,最好公司title大一点的
无实习如何秋招上岸
点赞 评论 收藏
分享
小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务