每日学习

void bubble_sort(int a[],int n)

{

chang=false;

for(i=n-1;change=TURE;i>1&&change;-i)

for (j=0;j<I;++j)

if(a[j]>a[j+1])

{

a[j]←→a[j+1];change=TURE;}

}






struct phone

{

int id;           

char name[20];   

float price;      

char loc[50];    

};

void fun(struct phone *p)

{

if(p->price>6000)

{

printf("手机价格超过6000,享受8折优惠,最终消费金额是%.2f\n",p->price*0.8);

}

else if(p->price>3000)

{

printf("手机价格超过3000,享受9折优惠,最终消费金额是%.2f\n",p->price*0.9);

}

else

{

printf("手机价格不足3000,暂无优惠,送您优惠券一张,最终消费金额是%.2f\n",p->price);

}

}

void main()

{

struct phone p;

printf("\t\t请输入手机编号:");

scanf("%d",&p.id);

printf("\t\t请输入手机名称:");

scanf("%s",p.name);

printf("\t\t请输入手机单价:");

scanf("%f",&p.price);

printf("\t\t请输入手机产地:");

scanf("%s",p.loc);

fun(&p);  调用时传递的地址,因为参数是指针类型


猜你喜欢

转载自blog.csdn.net/ly_959/article/details/78915270