帮忙做几道C语言的题

1.编写程序实现产品保修额的计算。如果本公司的产品,则使用期在1年(含1年)以内,免收保修额;使用期在1年以上并且在8年以下(含8年),收取保修额50元;使用期在8年以上,收取保修额10元。如果不是本公司的产品,则一律收取保修额200元。根据用户输入的信息,计算保修额。
2.有一人不小心打碎了一位妇女的一篮子鸡蛋,为了赔偿便询问篮子中有多少个鸡蛋,那妇女说,数量不清楚,只记得每次拿两个最后剩一个,每次拿三个最后剩2个,每次拿4个最后剩3个,每次拿5个最后剩4个。若一个鸡蛋0.4元,应至少应赔偿多少钱?
3输入长、宽、高,计算长方体的体积。
4输入一个摄氏温度值,要求输出华氏温度值,转换公式为f=9/5*C+32,其中C表示摄氏温度表示华氏温度.
5计算4!的值,在此基础上再计算5!的值.

用C++也行

第1个回答  2008-06-10
题1:
#include<stdio.h>
int main()
{
int year=0,money=0,temp=0;
printf("Please input product witch place made in:\n");
printf("1------------------Made in Our company.\n");
printf("2------------------Made in other company.\n");
scanf("%d",&temp);
switch(temp)
{
case 1: printf("Please input how many year you use this company:\n");
scanf("%d",&year);
if(year>=0&&year<=1) {money=0; printf("Protect to fix a fee is %d\n",money);}
else if(year>1&&year<=8){money=50;printf("Protect to fix a fee is %d\n",money);}
else {money=10;printf("Protect to fix a fee is %d\n",money);}
break;
case 2: money=200;
printf("Protect to fix a fee is %d\n",money);
break;
default: printf("input error!\n");
}
return 0;
题2:
#include<stdio.h>
int main()
{
int egg_num=0;
float fee=0.4,money;
for(egg_num=0;;egg_num++)
{
if((egg_num%2==1&&egg_num%3==2&&egg_num%4==3&&egg_num%5==4)) break;
}
money=fee*egg_num;
printf("The number of eggs is %d.\n",egg_num);
printf("The man shuold pay %f$.\n",money);
return 0;
}
题3:#include<stdio.h>
int main()
{
float lenth,width,height;
double volume;
printf("Please input lenth、width and height:\n");
scanf("%f %f %f",&lenth,&width,&height);
volume=lenth*width*height;
printf("The volume is %f.\n",volume);
return 0;
}
题4:#include<stdio.h>
int main()
{
float temperature;
double temperature1;
printf("Please input the temperature:\n ");
scanf("%f",&temperature);
temperature1=(float)(9/5)*temperature+32;
printf("The temperature you want is %f.\n",temperature1);
return 0;
}
题5:
#include<stdio.h>
int main()
{
int s=1,n=1;
for(n=1;n<=4;n++)
s=s*n;
printf("4!=%d\n",s);
s=s*5;
printf("5!=%d\n",s);
return 0;
}本回答被提问者采纳

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网