1938 - 超市卖电池
Time Limit : 1 秒
Memory Limit : 128 MB
雅斯超市里卖电池,每个电池2.5元,若数量达到10个,则可打8折。编写一程序,输入电池数量,输出购买电池需多少元钱(小数点后保留2位)。
Input
一行:一个整数,表示电池数量。
Output
一行:一个实型数据,表示购买电池需用多少钱,小数点后保留2位。
Examples
Input Format
15
Output Format
30.00
Solution C++
#include<iostream> using namespace std; int main() { int n; float qian; cin>>n; if (n>=10) qian=n*2.5*0.8; else qian=2.5*n; cout.precision(2); cout.setf(ios::fixed); cout<<qian<<endl; //system("pause"); return 0; }