changefunc
Submit solution
Points:
40 (partial)
Time limit:
1.0s
Memory limit:
256M
Authors:
Problem type
Allowed languages
Java 19, Java 8
題目說明
請參考底下程式碼,並請寫一個計算式為(x - y) * (x + y / 2)的函式
public class MyProgram {
public static void main(String[] args) {
// call a function to increment 0.5
int value = 5;
System.out.println(value);
double newValue = increment(value, 0.3);
System.out.println(newValue);
}
// function to increment a value
public static double increment(int x, double y) {
double result = x + y;
return result;
}
}
輸入限制 整數
輸入
x y
輸出
算出的結果
測試資料1 輸入
1 2
測試資料1 輸出
-2
Comments
題解