The problem description states that you are given an even integer n (2 ≤ n ≤ 10000). Your task is to first print all the odd numbers from 1 to n in ascending order, followed by printing all the even numbers in ascending order as well.
Input consists of an integer i (2 ≤ i < 30) indicating the number of test cases. Each test case contains a single even integer n. You should process each test case accordingly.
Output requires that for each test case, the first line prints all the odd numbers separated by spaces, and the second line prints all the even numbers also separated by spaces. Note that there should be a space at the end of each line, and a blank line should separate different test cases.
Sample Input
2
10
14
Sample Output
1 3 5 7 9
2 4 6 8 10
1 3 5 7 9 11 13
2 4 6 8 10 12 14
The provided code includes a C++ implementation that reads multiple test cases and processes each one. It uses vectors to store the odd and even numbers respectively. For each test case, it loops through numbers from 1 to n, checks whether they are odd or even, and adds them to the corresponding vector. Then, it prints the contents of both vectors with appropriate spacing and formatting. The code ensures that after each test case, the vectors are cleared to avoid data contamination in subsequent iterations.
It's important to note that the code may need some minor corrections, such as proper indentation and syntax, especially for the `for` loops and the use of `std::vector`. Also, the output format must strictly follow the requirement of having a trailing space on each line and a blank line between test cases. This kind of problem is common in programming contests and helps improve understanding of basic control structures and data handling in C++.
Electric Motor For Compressor,Air Compressor Asynchronous Motor,Compressor Asynchronous Motor,Adaptable Coaxial Motor
Jiangsu Hengchi Motor Technology Co., Ltd , https://www.hcemotor.com