哪位大虾帮忙看看这道题目的意思,急!!!

qzakou 2007-05-23 11:49:21
一道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
...全文
243 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
hellenzhang126 2007-11-27
  • 打赏
  • 举报
回复
to qzakou
你在华为还是在大族激光上班,大族激光软件工程师考题的类型是什么样的,能否例举一下
谢谢
kanhu 2007-05-24
  • 打赏
  • 举报
回复
帮你顶一下,希望高手来解决一下。
qzakou 2007-05-24
  • 打赏
  • 举报
回复
刚刚拿到题目的准确意思,task 1-4组合起来是画一棵树。task 1是树的生长规则,task 2是树枝生长规则,task 3是树颜色演变规则,task 4是用带方括弧的语法文件来记录树的生长信息。每一个任务都包含了前一个任务的功能,故此task 2的代码中含有task 1的代码,也能处理task 1中的参数。所以在task 2所举的那个例中,后面的三个字符串参数就是由task 1的代码来处理的。应该说,到task 2为止,两组参数(即树的生长规则和树枝生长规则)暂时还没什么关系,只不过是把task 1和task 2的功能写在一个.c文件中,用一个main函数来接收和处理这两组参数。大家只需要帮忙把task 2中提到的画线部分的功能实现即可,至于字符串替换功能(即task 1实现的功能)已有标答。谢谢!
qzakou 2007-05-24
  • 打赏
  • 举报
回复
我这里有原题(包含了task 1-4和两个附加的task,task 1已解决,可以提供源代码)的doc文档,若有需要,可以提供。

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧