chaxundayudingjiage.h

来自「C语言写的商品信息管理系统 学习数据结构」· C头文件 代码 · 共 55 行

H
55
字号
///////////////输出价格高于某个值的所有商品按价格排序输出 8 
void chaxundayudingjiage(struct shangpin shangp[],int count)
{
     struct shangpin sp[MAXLENTH];
     struct shangpin sptemb;
     int total=-1;
     int i=0,j=0;
     int price=0;
mylabel1:
     printf("\n\t\t 请输入最底价格:");
     scanf("%d",&price);getchar();
   	 if(price<0)
     {
         printf("\n\t\t 价格不能小于0!!");
goto mylabel1;
    }
     for(i=0;i<count;i++)
         if(shangp[i].price>=price)
         {
             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;
            }
     if(total<0)
     {
			system("cls");
			printf("\n\n\n\n\n\n\n");
			printf("\n\t\t 这个价格段没有商品\n\n");
			printf("\n\t\t 查询完成,按任意键继续其他操作...."); getchar();
	 }
	 else
	 {
         system("cls");
         printf("\n\t\t 商品信息如下:");
         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 _________________________________"); 
         }
         printf("\n\t\t 查询完成,按任意键继续其他操作...."); 
	     getchar();
	}
}

⌨️ 快捷键说明

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