promotion image of download ymail app
Promoted

C++ 加comments

http://i409.photobucket.com/albums/pp172/momoko_de...

可以解釋一下每一句的意思嗎~?

(不是真的每句,但重要的都要講一下..)

短短的意思就OK...

thanks xDD

我用的是microsoft visual C++ 2008 express edition

更新:
更新 2:

***********************

那個WARNING怎樣FIX??

THANKS>

更新 4:

oh...icic...

actually i need to put comments at the end (just like what i've done on the lower part)

well i want to know y u use them for:

void initCanvas()

void displayCanvas()

void plotFunction(double (*fn)(double x))

like....what comments should i put on the upper part?

thanks~

更新 5:

i'm just wondering... what compiler are u using?

更新 6:

what about them...?

double fn1(double x) { return 3.5 * sin(2 * PI * x / 8); }

double fn2(double x) { return sqrt(x); }

double fn3(double x) { return (A*x*x+B*x+C)/(x*x+1); }

for (x=XMIN;x<=XMAX;x+=xstep) means "plot values of x from XMIN to XMAX at

intervals depending on the Canvas size"?

更新 7:

void displayCanvas()

would u mind telling me more about it please~?

like...the meanings of the lines...

coz i have an exam coming up but i still dont know what the contents mean...

thx alot>

更新 8:

so does that mean whenever i make graphs, i need to use the three "void parts"?

1 個解答

評分
  • Wu
    Lv 5
    1 十年前
    最愛解答

    what exactly is the warning?

    2010-05-10 10:01:23 補充:

    This warning only happens to Microsoft Visual C++ and is due to the version compatibility. It can be ignored.

    For others, please specify which part of the program you don't understand so I could explain to you.

    2010-05-10 11:32:08 補充:

    /***********************************************

    Initialize the Canvas so that all members

    in the canvas matrix would be set to '.' (char).

    input: none

    return: none

    Output: Initialized canvas matrix

    ************************************************/

    void initCanvas()

    /***********************************************

    Display the content of the Canvas matrix on

    console screen. The function would also display

    labeled x and y axis at bottom and left side

    respectively.

    input: none

    return: none

    Output: On screen display of Canvas content

    ***********************************************/

    void displayCanvas()

    /***************************************************

    To plot an input function by setting appropriate

    members in the Canvas matrix to '*' according to

    the x,y coordinates of the functions. The functions

    always plot values of x from XMIN to XMAX at

    intervals depending on the Canvas size. If the y value

    returned from function is within the YMIN and YMAX

    value, an appropriate member of the Canvas matrix

    would be set. Otherwise, it is ignored.

    input: a function pointer to plot

    return: none

    Output: a plotted canvas matrix. (this function would

    also call displayCanvas() to display the result

    on screen.

    ****************************************************/

    void plotFunction(double (*fn)(double x))

    ps. I am using both MSVC++ and DevC++

    2010-05-10 12:27:13 補充:

    double fn1(double x)

    double fn2(double x)

    double fn3(double x)

    These are the three functions defined in your question. I just turn it into C programs.

    Yes, xstep is calculated from (XMAX-XMIN)/(XSIZE-1)

    displayCanvas() just show the content of the matrix on screen using printf directly.

    2010-05-11 21:36:24 補充:

    Yes. The steps to plot a new function:

    1. Create a function like double fn1(double x) that returns y when given x.

    2. call initCanvas() to initialize the plot area.

    3. call plotFunction(&fn1) by passing the function pointer created by 1 above. This function will also display the result.

    • Commenter avatar登入以回覆解答
還有問題嗎?立即提問即可得到解答。