㈠ c语言,请问这题怎么写代码呢
推测你的完整题目是:
某个服装店经营套服,也单件出售,如果整套买服装,一次购买的多于50套,每套80元;如果一次购买的不足50套,每套90元;如果只买上衣,每件60元;如是只买裤子,每条45元;输入需要购买的上衣和裤子的件数,计算应付金额。
#include<stdio.h>intmain(){
intshangyi,kuzi;
intchengtao,cost;
printf("请输入上衣件数和裤子件数: ");
scanf("%d%d",&shangyi,&kuzi);
chengtao=shangyi<kuzi?shangyi:kuzi;
cost=chengtao>=50?(chengtao*80):(chengtao*90);
cost+=(shangyi-chengtao)*60+(kuzi-chengtao)*45;
printf("应付金额:%d ",cost);
return0;
}
㈡ C语言编程,题目:周末商场促销,某品牌服装即可以买套装,又可以买单件,若买的不少于50套,每套80
#include<stdio.h>
int Get(int count)
{
if(count>=50)
return count*80;
else
return count*90;
}
int Pay(int shangyi,int kuzi)
{
int gold=0;
int left=0;
if(shangyi==kuzi)
gold=Get(shangyi);
else if(shangyi>kuzi)
{
gold=Get(kuzi);
left=shangyi-kuzi;
gold+=left*60;
}
else if(shangyi<kuzi)
{
gold=Get(shangyi);
left=kuzi-shangyi;
gold+=left*45;
}
return gold;
}
int main()
{
int shangyi=55;
int kuzi=50;
int gold=Pay(shangyi,kuzi);
printf("%d ",gold);
system("pause");
}
㈢ C语言买衣服最少用多少钱
#include<stdio.h>
#include<stdlib.h>
//衣服结构体
structclothes
{
floatfSellingPrice; //出售价格
floatfReturnPrice; //返还价格
};
int_tmain(intargc,_TCHAR*argv[])
{
intn=0;
printf("请输入购买衣服数量:");
scanf_s("%d",&n,sizeof(n));
//动态创建数量
clothes*p=newclothes[n];
inti=0;
intj=0;
for(i=0;i<n;i++)
{
printf("请输入第%d件衣服的价格和返还价格:",i+1);
scanf_s("%f,%f",&p[i].fSellingPrice,&p[i].fReturnPrice);
}
printf(" ");
floatfAllPrice=0; //总价格
floatfAllReturn=0; //总返现
//将其加和
for(i=0;i<n;i++)
{
//printf("%d,%.2f,%.2f ",i+1,p[i].fSellingPrice,p[i].fReturnPrice);
fAllPrice+=p[i].fSellingPrice;
fAllReturn+=p[i].fReturnPrice;
}
//总价格-总返现=最少需要花费价格
printf("最少需要花费价格为:%.2f ",fAllPrice-fAllReturn);
delete[]p;
p=NULL;
system("pause");
return0;
}
㈣ c语言编程 某服装批发商店经营套装,也单价出售,若买的不少于50套,每套80元,不足50套每套10
#include "stdio.h"
int main(void)
{
int imoney = 0;
int iWaist = 0;
int itrousers = 0;
printf("请分别输入需要买的上衣和裤子的数目:");
scanf("%d%d" ,&iWaist ,&itrousers);//可以加上对输入数值的正确性的判断
if ( iWaist >= itrousers )
{
if ( itrousers >= 50 )
{
imoney = itrousers * 80 + ( iWaist - itrousers )*60;
}
else
{
imoney = itrousers * 100 + ( iWaist - itrousers )*60;
}
}
else
{
if ( iWaist >= 50 )
{
imoney = iWaist * 80 + ( itrousers - iWaist )*45;
}
else
{
imoney = iWaist * 100 + ( itrousers - iWaist )*45;
}
}
printf("monye = %d\n", imoney);
return 0;
}
㈤ 用c语言编一个计算衣服价格的程序,要求一件衣服打九折,两件衣服7.8折,三件打五折,大于三件还是打
#include<stdio.h>
void calc(double prirce,int num){
double total;
if(num==1){
total = prirce*0.9;
}else if(num==2){
total = num*prirce*0.78;
}else{
total=num*prirce*0.5;
}
printf("你买了%d件衣服,衣服的总价格是%2f",num,total);
}
void main(){
double inputPrice[3]={41.56,782.4,87.93};
calc(inputPrice[0],2);
calc(inputPrice[1],3);
calc(inputPrice[2],1);
}
㈥ C语言。某服装店卖套装,若买的数量不少于50套,每套80;不足50套,每套90;单上衣60;单裤子45。求价钱
没有啊,我按照你的代码运行了,一下,输入的都是60 ,最终结果为4800,60*80=4800。你想多了,或者手抖了。
㈦ C语言的数学题
如果一次买的数量等于50套呢?
#include<stdio.h>
intsmall(inta,intb)
{
if(a>b)
a=b;
returna;
}
intmain()
{
inttops,pants,temp,sum=0;
scanf("%d%d",&tops,&pants);
if(tops==pants)
{
if(tops>50)
sum=tops*80;
else
sum=tops*90;
}
else
{
temp=small(tops,pants);
if(temp>50)
sum=temp*80;
elseif(temp<50)
sum=temp*90;
if(tops>pants)
sum+=(tops-pants)*60;
elseif(tops<pants)
sum+=(pants-tops)*45;
}
printf("%d ",sum);
return0;
}