⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chaxunzhidingjiage.h

📁 C语言写的商品信息管理系统 学习数据结构
💻 H
字号:
///////////////任意指定对商品进行价格排序        11
void chaxunzhidingjiage(struct shangpin shangp[],int count)
{
    struct shangpin sp[MAXLENTH];
    struct shangpin sptemb;
    int total=-1;
    int i=0,j=0;
    int low,high;
   	printf("\n\t\t 请输入最底价格:");
   	scanf("%d",&low);
   	printf("\n\t\t 请输入最高价格:");
   	scanf("%d",&high);
    for(i=0;i<count;i++)
	{
		if(shangp[i].price>low && shangp[i].price<high)
		{
            total=total+1;
            sp[total]=shangp[i];;
	   	}
	}
     for(i=0;i<total;i++)
     {
         for(j=total;j>i;j--)
            if(sp[j-1].price>sp[j].price)
            {
                sptemb=sp[j];
                sp[j]=sp[j-1];
                sp[j-1]=sptemb;
            }
     }
     for(i=0;i<=total;i++)
     {
         printf("\n\t\t _________________________________"); 
         printf("\n\t\t 商品编号:%d",sp[i].id); 
         printf("\n\t\t 商品名称:%s",sp[i].spname); 
         printf("\n\t\t 商品价格:%.2f",sp[i].price); 
         printf("\n\t\t 商品库存:%d",sp[i].kucun); 
     }
     printf("\n\t\t 查询完成,按任意键继续其他操作...."); 
	 getchar();getchar();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -