Assume that you will be given a *.txt file, which in the same format of RandSource.txt(attached). The file has three numbers at each line. Numbersare separated with a space. All number are in the range of [0, 50]. The first two numbers indicate a range. The third one shows number of random numbers to be generated in the range of first two numbers. The range always given in first < second order. If not, raise an error. For instance, 2 5 7 means that you need to generate 7 random numbers in the range of 2 - 5 (including 2 and 5). You need to develop a complete C++ program to read each line from the .txt file and print the result on screen in a formatted way. The output format will be <first number> - <second number>: <random numbers > . For the above example, the output to screen should be 2 - 5: 6 5 4 6 3 7 5The attached input file has,3 6 82 19 104 12 41 6 07 4 30 8 310 9 8Your program should generate this (or with different random numbers) output for this file3 - 6: 5 4 3 5 6 3 4 52 - 19:6 2 11 14 17 9 8 19 2 7 4 - 12:5 4 10 91 - 6: // no output here since quantity is 07 - 4:error0 - 8:0 6 410 - 9: error Note that your program should any number of lines in the file. You strictly assume that all numbers are in the range of [0,50]. RandSource.txt: 3 6 82 19 104 12 41 6 07 4 30 8 310 9 8
Assume that you will be given a *.txt file, which in the same format of RandSource.txt(attached). The file has three numbers at each line. Numbersare separated with a space. All number are in the range of [0, 50]. The first two numbers indicate a range. The third one shows number of random numbers to be generated in the range of first two numbers. The range always given in first < second order. If not, raise an error.
For instance,
2 5 7 means that you need to generate 7 random numbers in the range of 2 - 5 (including 2 and 5).
You need to develop a complete C++ program to read each line from the .txt file and print the result on screen in a formatted way. The output format will be <first number> - <second number>: <random numbers > . For the above example, the output to screen should be
2 - 5: 6 5 4 6 3 7 5
The attached input file has,
3 6 8
2 19 10
4 12 4
1 6 0
7 4 3
0 8 3
10 9 8
Your program should generate this (or with different random numbers) output for this file
3 - 6: 5 4 3 5 6 3 4 5
2 - 19:6 2 11 14 17 9 8 19 2 7
4 - 12:5 4 10 9
1 - 6: // no output here since quantity is 0
7 - 4:error
0 - 8:0 6 4
10 - 9: error
Note that your program should any number of lines in the file. You strictly assume that all numbers are in the range of [0,50].
RandSource.txt:
3 6 8
2 19 10
4 12 4
1 6 0
7 4 3
0 8 3
10 9 8
Trending now
This is a popular solution!
Step by step
Solved in 7 steps with 7 images