哪位大虾帮忙看看这道题目的意思,急!!!
一道c语言的题目,原文如下:
Task 2 [6 marks]
Translate the string of drawing commands into a sequence of lines in a two-dimensional space. Each line is characterized by the following values:
• X- and Y-coordinate of the starting point
• X- and Y-coordinate of the end point point
• a triple of double precision floating point values between 0 and 1 describing the color of the line as RGB (Red-Green-Blue) value. For example, (1 0 0) is red, (1 1 1) white, (0 0 0) black.
For this task, you can ignore the [ and ] commands. Your program should read the following data from standard input:
• Line length
• Initial drawing directions given as radian, that is:
• 0
• ^
• |
• 1.5 Pi <-o-> 0.5 * Pi
• |
• V
• Pi
• Angle: the angle by which + and - change the current direction, given as radian. For example, if the angle is 0.5 Pi, then + changes the direction by 90 degrees clockwise, - anticlockwise. To use the C functions sin and cos, you need to include math.h.
• The grammar (format as for Task 1) that describes the picture
and the number of iterations (as for Task 1) as command line argument.
Contents of an example file:
100
0.0
0.3926
F
F
F+F
The line length is 100 pixels, the initial direction straight up, the angle (roughly) Pi/8 or 22.5 degrees, the start string F, the rule F -> F+F. The output of your program should be the sequence of lines produced by interpreting the commands of this string, each line in the format
xStart yStart xEnd yEnd R G B
where the x- and y values should be rounded down to integer values, and the RGB values are double precision floating point values. For this task, we set the lines to red (1.0 0.0 0.0).
Sample files
View with lineViewer < data_spiral200.in.
• Monochrome Spiral, line output for 10, 200 iterations
输出格式为:
xstart ystart xend yend R G B。(r,g,b这几个参数代表颜色值,就像windows编程里面那个RGB值)
按照题目要求输入的意思为,首先要输入一个长度值,第二个参数是一个原始方向的值,第三个参数是直线方向改变值,最后的输入为一个语法,为一个字符串的替换规则,如abcd a bcd 输出为bcdbcd。
这里有一个示例的输入:
100
0.0
0.39269908169872414
FT
M
FM
T
FMF+FMT
注意,第一次替换是不起作用的,因为字符串中没有这个字符,只有第二次替换会起作用,替换后变成:FFMF+FMT,现在不懂这个替换后的字符串到底跟输出结果有什么联系。
这里有三个链接,一个是输入,其他两个是输出。题目中这段话有个提示,但没理解什么意思:•Monochrome Spiral, line output for 10, 200 iterations ,单色螺旋,10次和200次迭代输出(不知道翻译得怎么样)。
这个是例子输入的链接:http://www.cse.unsw.edu.au/~cs1911/assignments/2/task2_samples/spiral.txt,
这个是输出的链接:10次的
http://www.cse.unsw.edu.au/~cs1911/assignments/2/task2_samples/data_spiral10.in
200次的:
http://www.cse.unsw.edu.au/~cs1911/assignments/2/task2_samples/data_spiral200.in