输入格式:
输入在一行中给出商品的原价(不超过1万元的正整数)和折扣(为[1, 9]区间内的整数),其间以空格分隔。
输出格式:
在一行中输出商品的折扣价,保留小数点后 2 位。
输入样例:
988 7
结尾无空行
输出样例:
691.60
结尾无空行
代码如下:
#include <stdio.h>
int main(void){
double price ; //商品原价
int discount ; //折扣
double totalPrice ; //最后总价
//从输入依次读入原价和折扣
scanf("%lf %d",&price,&discount);
//计算最后总价
totalPrice = price * discount / 10;
//打印最后总价, .2lf用于打印double类型总价,以2为小数点显示。
printf("%.2lf",totalPrice);
return 0;
}