简体   繁体   中英

splitting a string into different arrays

My input format the number of types of items, followed by N (N - no.of items) lines each representing a pair of integers in the format LB where L is the length of the item and B is the breadth of the item.

Sample input format:
2
1 1
5 4

My question is how send all lengths into one array and all breadths into one array with out using vectors in C++. I know these kind of questions were already asked by people but I couldn't figure out how to send them to two different arrays.

my program should run in a sandbox. Sandbox automatically gives input to the program. So I have to write my program in a way that takes the above input format

cin >> n;
int *l,*b;
l = new int[n];
b = new int[n];

for(int i=0; i<n; ++i) {
  cin >> l[i] >> b[i];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM