運算結果不對!!求助?。?/h1>
#include <stdio.h>
????int gz(float a, int b) { ? ? ? ? ? ? /*定義路程 時間*/
????float c = 2.3;
????int x = 3;
????int z = 1;
????float zhonghe;
????if (b <= 23 || b >= 6) { ? ?????????/*判斷時間是否在23點前還是在6點后*/
????c = c * 1.2;
????}
????if (x == 3) { ?????????????????/*起步3公里 */
????a = 9;
????zhonghe = c * a+ 13 + z;
????return zhonghe;
????}
????}
????int main()
????{
????float cc = gz(12, 6);
????printf("%f", cc);
????getchar();
????return 0;
????}
*******************************************************************
結果是38 ?我用計算器算了結果應該是34.多少來著我忘了。
#include <stdio.h>
????int gz(float a, int b) { ? ? ? ? ? ? /*定義路程 時間*/
????float c = 2.3;
????int x = 3;
????int z = 1;
????float zhonghe;
????if (b <= 23 || b >= 6) { ? ?????????/*判斷時間是否在23點前還是在6點后*/
????c = c * 1.2;
????}
????if (x == 3) { ?????????????????/*起步3公里 */
????a = 9;
????zhonghe = c * a+ 13 + z;
????return zhonghe;
????}
????}
????int main()
????{
????float cc = gz(12, 6);
????printf("%f", cc);
????getchar();
????return 0;
????}
*******************************************************************
結果是38 ?我用計算器算了結果應該是34.多少來著我忘了。
2018-07-31
#include <stdio.h>
int main()
{
? ? double s;
? ? s=13+2.3*(12-3)+1;
? ? printf("%f",s*2);
? ? return 0;
}