當前位置:首頁 » 編程語言 » c語言買衣服多少錢一套
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言買衣服多少錢一套

發布時間: 2023-01-26 03:07:36

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;
}