编程练习

#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2; // 读取两个点的坐标 
    int dx = abs(x2 - x1);
    int dy = abs(y2 - y1);// 坐标差值    
    int manhattan = dx + dy;// 曼哈顿距离
    int chebyshev = max(dx, dy);// 切比雪夫距离
    cout << manhattan << " " << chebyshev << endl;
    return 0;
}
#include <iostream>
using namespace std;

int main() {
    int total_minutes = 0;
    for (int i = 0; i < 3; i++) {//读取时间段
        int h1, m1, h2, m2;
        cin >> h1 >> m1 >> h2 >> m2;
        int start_m = h1 * 60 + m1;
        int end_m = h2 * 60 + m2;
        total_m += (end_m - start_m);
    }
    int hours = total_m / 60;
    int minutes = total_m% 60; // 转换成小时和分钟
    cout << hours << " " << minutes << endl;
    if (hours >= 4) {// 判断结果
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


 


}
#include <iostream>
using namespace std;
int main(){
    cout<<"Hello excellent athletes!"<<endl;
    cout<<"Hello excellent acmers!"<<endl;
    cout<<"Welcome to HZNU!"<<endl;
    return 0;
}

 

posted @ 2025-10-23 23:02  bluepoet  阅读(3)  评论(0)    收藏  举报