0
点赞
收藏
分享

微信扫一扫

计算面积 华为机试

夏侯居坤叶叔尘 2022-03-31 阅读 40
java

【代码】

package Huawei;

import java.util.Scanner;

/**
 * @description:
 * @author: Polaris
 * @date: 2022/3/30 23:24
 */
public class no13 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()) {
            int area=0,preX = 0,preY=0;
            int n1 = sc.nextInt();
            int maxX = sc.nextInt();
            for(int i=0;i<n1;i++){
                int nowX = sc.nextInt();
                int nowY = sc.nextInt();
                area += (nowX-preX)*preY;
                preX = nowX;
                preY+=nowY;
            }
            area += preY*(maxX-preX);
            System.out.print(area);
        }
    }
}
举报

相关推荐

0 条评论