void main()
{
float n[4],apple=2.5,pear=1.8,banana=2,orange=1.6,price,charge,money
printf("请输入水果重量苹果 鸭梨 香蕉 橘子 (不买的水果请输芹搜携入0): \n")
int i
for(i=0i<4i++)scanf("%f",&n[i])
printf("应付钱 %.2f 元\n",price=apple*n[0]+pear*n[1]+banana*n[2]+orange*n[3])
printf("请输入付款数:漏乱")scanf("%f",&money)
printf("应找钱 %.2f 元\n",money-price)
}
#include<stdio.h>void fun(){
int i, ch 带瞎唤float price = 9.8, in_price, total = 0 while (1){
printf("\n1.算账模式\n2.算账\n3.退出\n")
scanf("%d", &i)
switch (i){
case 1://算账模式
{
do{
printf("应付款金额 %f 元.\n付款金额:", price)
scanf("%f", &in_price)
printf("实际付款金额%f,应找零金额 %f 元.\n", in_price, in_price - 蠢凯price)
total += price
scanf("%d", &ch)
} while (ch != -1)
break
}
case 2:{
神拆 printf("收款总额:%6.2f 元.\n", total) break
}
case 3:
exit(0)
}
}
}
void main()
{
fun()
}
#include <stdio.h>int main(void)
{
float p[4] = {3.2, 1.96, 3, 24}
float w[4] = {1.5, 2, 3, 1.5}
float s = 0
int i
for(i=0i<4i++)
s+= p[i]*w[i]
printf("%s%12s%12s%13s\n", "名称", "单价", "重量", "应付价钱")
printf("---------------------------------------------\n")
printf("%s%12.2f%12.2f%13.3f\n","苹果"液枝, p[0], 吵盯w[0], p[0]*w[0])
printf("%s%12.2f%12.2f%13.3f\n","梨 ", p[1], w[1], p[1]*w[1])
printf("%s%12.2f%12.2f%13.3f\n","香蕉", p[2], w[2], p[2]*w[2])
printf("%s%12.2f%12.2f%13.3f\n","樱桃", p[3], w[3], p[3]*w[3])
printf("---------------------------------------------\n")
printf("%s%37.2f\n", "总计", s)
printf("%s%37.2f\n"升埋和, "付款", 100.0)
printf("%s%37.2f\n", "找零", 100.0 - s)
return 0
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)