问题:重量小于一大于零时统一为10块钱,重量大于1时,砍去一开始的一公斤。每公斤6块钱,有小数的取整进一。编译可以通过但是输数字的环节出了问题,跳出来为乱码啥的。
代码:
#include<stdio.h>
int main(void)
{
/Begin/
int weight1,a;
float weight;
scanf("%f",weight);
if(weight<=1 && weight>0)
a=10;
printf("Price: %.2f",a);
if(weight>1)
weight1=(int)weight;
a=weight1*10+10;
printf("Price: %.2f",a);
/*********End**********/
}#include<stdio.h>
int main(void)
{
/*********Begin*********/
int weight1,a;
float weight;
scanf("%f",weight);
if(weight<=1 && weight>0)
a=10;
printf("Price: %.2f",a);
if(weight>1)
weight1=(int)weight;
a=weight1*6+10;
printf("Price: %.2f",a);
/*********End**********/
}