當前位置:編程學習大全網 - 編程軟體 - 在C語言中有下題 求怎麽寫代碼

在C語言中有下題 求怎麽寫代碼

//希望我的回答對妳的學習有幫助

#include?<stdio.h>

int?main()

{

float?OriginalPrice,?PresentPrice;

int?UseTime;

while?(1)

{

printf("Please?input?the?use?time?and?original?price:(sample:8?10000)\n");

scanf_s("%d?%f",?&UseTime,?&OriginalPrice);

if?(UseTime?<?0)?break; //輸入負數,結束程序

if?(UseTime?<?3)?PresentPrice?=?OriginalPrice;

else?if?(UseTime?>=?3?&&?UseTime?<?6)?PresentPrice?=?OriginalPrice?*?0.02;

else?if?(UseTime?>=?6?&&?UseTime?<?12)?PresentPrice?=?OriginalPrice?*?0.05;

else?if?(UseTime?>=?12?&&?UseTime?<?21)?PresentPrice?=?OriginalPrice?*?0.08;

else?PresentPrice?=?OriginalPrice?*?0.1;

printf("The?Depreciation?price?is?:?%.2f\n\n",?PresentPrice); //保留兩位小數點

}

return?0;

}

  • 上一篇:三菱PLC DRVI指令
  • 下一篇:西安理工大學高數競賽算創新成果獎嗎
  • copyright 2024編程學習大全網