2024 ccfcsp认证打卡 2023 09 01 坐标变换(其一)

java 复制代码
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();  // 操作次数
        int m = in.nextInt();  // 初始坐标个数
        int temp_x = 0;  // 临时存储x的累加值
        int temp_y = 0;  // 临时存储y的累加值

        // 第一阶段:累加n个操作的(dx, dy)值
        for( int i = 1; i <= n; i++ ) {
            int x = in.nextInt();
            int y = in.nextInt();
            temp_x += x;  // 将当前读入的x累加到temp_x
            temp_y += y;  // 将当前读入的y累加到temp_y
        }

        // 第二阶段:对每个初始坐标进行操作
        for( int i = 1; i <= m; i++ ) {
            int x = in.nextInt();  // 读取初始坐标的x值
            int y = in.nextInt();  // 读取初始坐标的y值
            x += temp_x;  // 将temp_x累加到初始坐标的x上
            y += temp_y;  // 将temp_y累加到初始坐标的y上
            System.out.println(x + " " + y);  // 输出最终坐标
        }
    }
}
相关推荐
叫致寒吧10 分钟前
Tomcat详解
java·tomcat
同学小张1 小时前
【端侧AI 与 C++】1. llama.cpp源码编译与本地运行
开发语言·c++·aigc·llama·agi·ai-native
踢球的打工仔2 小时前
PHP面向对象(7)
android·开发语言·php
S***26754 小时前
基于SpringBoot和Leaflet的行政区划地图掩膜效果实战
java·spring boot·后端
汤姆yu4 小时前
基于python的外卖配送及数据分析系统
开发语言·python·外卖分析
Yue丶越4 小时前
【C语言】字符函数和字符串函数
c语言·开发语言·算法
马剑威(威哥爱编程)5 小时前
鸿蒙6开发视频播放器的屏幕方向适配问题
java·音视频·harmonyos
JIngJaneIL5 小时前
社区互助|社区交易|基于springboot+vue的社区互助交易系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·社区互助
翔云 OCR API5 小时前
人脸识别API开发者对接代码示例
开发语言·人工智能·python·计算机视觉·ocr
V***u4535 小时前
MS SQL Server partition by 函数实战二 编排考场人员
java·服务器·开发语言