13705 - Struct - Exercises   

Description

給定一個名為Exercise的struct,如下列所示:

Exercise

          - int x

          - int y

          - char op

 

再給定主要執行程式main.c (題號.c)、以及Header檔function.h (題號.h);請試著完成Header檔中未實現的函式:SetValue()、GetAnswer()

Methods:

void SetValue(Exercise* ex, double _x, double _y, char _op) - Should set ex's x value to _xex's y value to _yex's op value to _op

void GetAnswer(Exercise ex) - Should return the answer of the math exercise ex

 

function.c

#include "function.h"
 
void SetValue(Exercise *ex, double _x, double _y, char _op)
{
    // TODO
}
 
double GetAnswer(Exercise ex)
{
    // TODO
}

Input

輸入符合以下格式

op x1 y1

 

Note:

  1. op 只會出現 '+', '-', '*', '/'
  2. 不會出現不合理的數值運算,例如除以0
  3. 無需處理輸入

Output

輸出符合以下格式:

x op y = ans

 

Note:

  1. 輸出的最後必須要有一個換行符號 ('\n')
  2. 無需處理輸出

Sample Input  Download

Sample Output  Download

Partial Judge Code

13705.c

Partial Judge Header

13705.h

Tags




Discuss