Question On How to Read Multiple Values For Each Single Line Test Case From Input Stream

Revision en1, by sjp1114, 2022-08-12 21:04:57

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!

Tags help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English sjp1114 2022-08-12 21:04:57 926 Initial revision (published)