Блог пользователя sjp1114

Автор sjp1114, история, 2 года назад, По-английски

include <bits/stdc++.h>

using namespace std;

int number; int l1,r1,l2,r2;

int main(){ cin >> number; for(int i = 0; i < number; i++){ cin >> l1 >> r1 >> l2 >> r2; //basically, check if the minimum number of min. or max. required //falls in range of minimums and maxiums that must appear for //valid beautiful array! if(l2<=l1<=r2 or l1<=l2<=r1){ cout << max(l1, l2) << endl; continue; } else{ cout << l1 + l2 << endl; } } }

Basically, the input first line contains number of test cases. And for the following lines, each line is a test case containing each 4 integers, each separated by white space character. I was wondering what would be a good way to read from this for each test case. Thanks!

  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
2 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I create another function solve and then write a cycle.

void solve() {
    
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int st = 1;
    cin >> st;
    while(st--) {
        solve();
    }
    return 0;
}