Codeforces Round #535 (Div. 3) a题

http://codeforces.com/contest/1108/problem/A

题解:一段数轴上四个点,l1,r1,l2,r2,分别在l1,r1取一点,在l2,r2中取一点

#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int l1,r1,l2,r2;
        cin >> l1 >> r1 >> l2 >> r2;
        vector<int>a({l1,r1,l2,r2}); //容器,压缩
        int ans1 = 0,ans2 = 0;

        for(auto it :a)for(auto jt : a){
        if( l1 <= it && it <= r1 && l2 <= jt && jt <= r2 && it != jt)
        {
            ans1 = it;
            ans2 = jt;
        }

        }
        cout << ans1 << " " << ans2 << endl;

    }
return 0;
}

for(auto &a:str)就相当于for循环 &a就相当于int i=0;,遍历数组str

原文地址:https://www.cnblogs.com/ygbrsf/p/12583033.html