智慧物流管理系统(C语言实现)

主页面部分

智慧物流管理系统(C语言实现)_第1张图片

#include

#include

#include

struct cargo

{

 char num[100];

 float weight;

 char destin; //郑州:1 洛阳:2 商丘:3 濮阳:4 新乡:5 周口:6 信阳:7

 char way; //航运:s 铁路:r 管道:p 水运:w 公路:h

}stu[1000];

 

int main()

{

 void welcome();

 void input(struct cargo stu[]); 

 void sort(struct cargo stu[]); 

 void output(struct cargo stu[]); 

 void lookall(struct cargo stu[]); 

 void search(struct cargo stu[]); 

 welcome(); 

 return 0; 

}

 

void welcome()

{

 system("color f1"); 

 system("cls");

    printf("\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t-----------------------------\n"); 

    printf("\t\t\t\t\t\t| 欢迎使用物流仓储管理系统 |\n"); 

    printf("\t\t\t\t\t\t| 请选择以下操作: |\n"); 

    printf("\t\t\t\t\t\t| 1.货物入库 |\n"); 

    printf("\t\t\t\t\t\t| 2.货物出库 |\n");

    printf("\t\t\t\t\t\t| 3.货物信息 |\n"); 

    printf("\t\t\t\t\t\t| 4.货物查询 |\n"); 

    printf("\t\t\t\t\t\t| 5.货物盘点 |\n"); 

    printf("\t\t\t\t\t\t-----------------------------\n"); 

    void input(struct cargo stu[]); 

 void output(struct cargo stu[]); 

 void sort(struct cargo stu[]);

    void lookall(struct cargo stu[]); 

 void search(struct cargo stu[]); 

 int choose;

    scanf("%d",&choose); 

 switch(choose)

 {

  case 1:input(stu);

  break;

  case 2:output(stu);

        break;

        case 3:lookall(stu);

        break;

        case 4:search(stu);

        break;

        case 5:sort(stu);

        break;

    }

}

输入功能

智慧物流管理系统(C语言实现)_第2张图片

(P:这里不知道怎么回事,for循环内的while语句在不符合条件的情况下依然执行,有明白的小伙伴可以踢我一下!)

void input(struct cargo stu[]) //入库 

{

 system("cls"); 

 FILE *fp;

 if((fp=fopen("C:\\Users\\29752\\Desktop\\cargo.txt","r"))==NULL)

 {

  fp=fopen("C:\\Users\\29752\\Desktop\\cargo.txt","w"); 

  fclose(fp);

 }

 fp=fopen("C:\\Users\\29752\\Desktop\\cargo.txt","a"); 

 int i,j,n;

    printf("请输入您要入库的货物数:"); 

 scanf("%d",&n);

    printf("请输入货物的数据:\n"); 

 for(i=0;i

 {

  printf("订单编号:"); 

  scanf("%s",stu[i].num);

        fprintf(fp,"订单编号:%s\n",stu[i].num); 

  printf("货物重量(以kg为单位):"); 

  scanf("%f",&stu[i].weight);

        fprintf(fp,"货物重量:%f kg\n",stu[i].weight); 

  printf("运送目的地:\n");

  printf("请注意:下述英文编号代表不同地区,您仅需要键入编号即可。\n"); 

  printf("郑州:1 洛阳:2 商丘:3 濮阳:4 新乡:5 周口:6 信阳:7\n"); 

  scanf("%c",&stu[i].destin);

        fprintf(fp,"%c\n",stu[i].destin); 

  int c;

        int retu1(char a);

        c=retu1(stu[i].destin); 

  while(c!=1)

  {

   printf("输入有误,请重新输入地区编号:\n"); 

   scanf("%c",&stu[i].destin); 

   c=retu1(stu[i].destin);

  }

  printf("运送方式:\n");

        printf("请注意:下述英文编号代表不同运输方式,您仅需要键入编号即可。\n"); 

  printf("航运:s 铁路:r 管道:p 水运:w公路:h\n"); 

  scanf("%c",&stu[i].way);

        fprintf(fp,"%c\n",stu[i].way); 

  int d;

        int retu2(char a); 

  d=retu2(stu[i].way);

  while(d!=1)

  {

   printf("输入有误,请重新输入运输方式编号:\n"); 

   scanf("%c",&stu[i].way); 

   d=retu2(stu[i].way);

  }

        printf("\n");

    }

    printf("您的全部入库货物数据为:\n"); 

 for(j=0;j

 {

  printf("订单编号:%s货物重量:%.2f ",stu[j].num,stu[j].weight,stu[j].way); 

  switch(stu[j].destin)

  {

   case '1':printf("运送目的地:郑州 ");

   break;

   case '2':printf("运送目的地:洛阳 ");

   break;

   case '3':printf("运送目的地:商丘 ");

   break;

   case '4':printf("运送目的地:濮阳 ");

   break;

   case '5':printf("运送目的地:新乡 ");

   break;

   case '6':printf("运送目的地:周口 ");

   break;

   case '7':printf("运送目的地:信阳 ");

   break; 

  }

        switch(stu[j].way)

        {

         case 's':printf("运送方式:航运\n");

   break;

   case 'r':printf("运送方式:铁路\n");

   break;

   case 'p':printf("运送方式:管道\n");

   break;

   case 'w':printf("运送方式:水运\n");

   break;

   case 'h':printf("运送方式:公路\n");

   break;

  }

    }

 fclose(fp);

 printf("货物入库成功!\n");

 printf("\n【返回主页面请按1,退出本系统请按2】\n"); 

 int h;

 scanf("%d",&h);

 switch(h)

 {

  case 1:welcome();

        break;

        case 2:break;

 }

}

 

int retu1(char a)

{

 if(a=='1') return 1; 

 if(a=='2') return 1; 

 if(a=='3') return 1; 

 if(a=='4') return 1; 

 if(a=='5') return 1;

 if(a=='6') return 1;

 if(a=='7') return 1;

 else return 0;

}

int retu2(char a)

{

 if(a=='s') return 1; 

 if(a=='r') return 1; 

 if(a=='p') return 1; 

 if(a=='w') return 1; 

 if(a=='h') return 1;

 else return 0;

}

(P:输入的货物信息可以保存在文本文档里)

智慧物流管理系统(C语言实现)_第3张图片

输出功能

智慧物流管理系统(C语言实现)_第4张图片

 void output(struct cargo stu[]) //出库

{

 system("cls"); 

 int i,flag=0; 

 char a[100];

 printf("请输入需要出库的订单编号:"); 

 scanf("%s",&a);

 for(i=0;stu[i].weight!=0;i++)

 {

  if(strcmp(a,stu[i].num)==0)

  flag=1; 

  if(flag)

  {

   strcpy(stu[i].num,stu[i+1].num); 

   stu[i].weight=stu[i+1].weight; 

   stu[i].destin=stu[i+1].destin; 

   stu[i].way=stu[i+1].way;

     }

    }

    printf("货物出库成功!\n");

 printf("\n【返回主页面请按1,退出本系统请按2】\n"); 

 int h;

 scanf("%d",&h); 

 switch(h)

 {

  case 1:welcome();

  break; 

  case 2:break;

 }

}

全览功能

智慧物流管理系统(C语言实现)_第5张图片

 void lookall(struct cargo stu[]) //全览

{

 system("cls"); 

 int j;

 printf("您的全部货物数据为:\n"); 

 for(j=0;stu[j].weight!=0;j++)

 {

  printf("订单编号:%s货物重量:%.2f",stu[j].num,stu[j].weight,stu[j].way); 

  switch(stu[j].destin)

  {

   case'1':printf("运送目的地:郑州 ");

   break;

   case'2':printf("运送目的地:洛阳 ");

   break;

   case'3':printf("运送目的地:商丘 ");

   break;

   case'4':printf("运送目的地:濮阳 ");

   break;

   case'5':printf("运送目的地:新乡 ");

   break;

   case'6':printf("运送目的地:周口 ");

   break;

   case'7':printf("运送目的地:信阳 ");

   break; 

  }

  switch(stu[j].way)

  {

   case's':printf("运送方式:航运\n");

   break;

   case'r':printf("运送方式:铁路\n");

   break;

   case'p':printf("运送方式:管道\n");

   break;

   case'w':printf("运送方式:水运\n");

   break;

   case'h':printf("运送方式:公路\n");

   break;

  }

 }

 printf("\n【返回主页面请按1,退出本系统请按2】\n"); 

 int h;

 scanf("%d",&h); 

 switch(h)

 {

  case 1:welcome();

  break; 

  case 2:break;

 }

}

查询功能

智慧物流管理系统(C语言实现)_第6张图片

 void search(struct cargo stu[]) //按订单编号查询

{

 system("cls"); 

    char s[30]; 

 int j; 

 int y=0;

    printf("请输入货物订单编号:"); 

 scanf("%s",s);

    for(j=0;stu[j].weight!=0;j++)

    {

     if(strcmp(stu[j].num,s)==0)

  {

   y=1;

            printf("订单编号:%s 货物重量:%.2f ",stu[j].num,stu[j].weight,stu[j].way); 

   switch(stu[j].destin)

   {

    case'1':printf("运送目的地:郑州 ");break; 

    case'2':printf("运送目的地:洛阳 ");break; 

    case'3':printf("运送目的地:商丘 ");break; 

    case'4':printf("运送目的地:濮阳 ");break; 

    case'5':printf("运送目的地:新乡 ");break; 

    case'6':printf("运送目的地:周口 ");break; 

    case'7':printf("运送目的地:信阳 ");break;

   }

   switch(stu[j].way)

   {

    case's':printf("运送方式:航运\n");break;

    case'r':printf("运送方式:铁路\n");break;

       case'p':printf("运送方式:管道\n");break;

       case'w':printf("运送方式:水运\n");break;

       case'h':printf("运送方式:公路\n");break;

   }

  }

 }

 if(!y)

    printf("未找到该货物!\n");

    printf("\n【返回主页面请按1,退出本系统请按2】\n");

    int h; 

 scanf("%d",&h); 

    switch(h)

    {

     case 1:welcome();break; 

  case 2:break;

 }

}

分类功能

智慧物流管理系统(C语言实现)_第7张图片

 void sort(struct cargo stu[]) //分类

{

 system("cls");

    void weight(struct cargo stu[]);

    void destination(struct cargo stu[]); 

 void way(struct cargo stu[]); 

 int num;

 printf("根据重量盘点请按 【1】\n"); 

    printf("根据目的地盘点请按 【2】\n"); 

    printf("根据运输方式盘点请按【3】\n"); 

 scanf("%d",&num); 

 switch(num)

 {

  case 1:weight(stu);

  break;

        case 2:destination(stu);

  break;

        case 3:way(stu);

  break;

        default:printf("无效数字!请输入正确的数字啦~\n");

 }

 printf("\n【返回主页面请按1,退出本系统请按2】\n"); 

 int h;

    scanf("%d",&h); 

 switch(h)

 {

  case 1:welcome();

  break; 

  case 2:break;

 }

}

void weight(struct cargo stu[])

{

 int i,a=0,b=0,c=0,d=0,e=0,f=0; 

 for(i=0;stu[i].weight!=0;i++)

 {

  if(stu[i].weight>0&&stu[i].weight<1)a++;

  else if(stu[i].weight>=1&&stu[i].weight<5)b++; 

  else if(stu[i].weight>=5&&stu[i].weight<15)c++; 

  else if(stu[i].weight>=15&&stu[i].weight<30)d++; 

  else if(stu[i].weight>=30&&stu[i].weight<50)e++; 

  else if(stu[i].weight>=50)f++;

 }

 printf("重量(0,1)的货物数:%-5d\n",a); 

 printf("重量[1,5)的货物数:%-5d\n",b); 

 printf("重量[5,15)的货物数:%-5d\n",c);

 printf("重量[15,30)的货物数:%-5d\n",d);

 printf("重量[30,50)的货物数:%-5d\n",e);

 printf("重量[50,+∞)的货物数:%-5d\n",f);

}

void destination(struct cargo stu[])

{

 int i,a=0,b=0,c=0,d=0,e=0,f=0,g=0; 

 for(i=0;stu[i].weight!=0;i++)

 {

  if(stu[i].destin=='1')a++;

  else if(stu[i].destin=='2')b++; 

  else if(stu[i].destin=='3')c++; 

  else if(stu[i].destin=='4')d++; 

  else if(stu[i].destin=='5')e++; 

  else if(stu[i].destin=='6')f++; 

  else if(stu[i].destin=='7') g++;

 }

 printf("郑州的货物数:%-5d\n",a); 

 printf("洛阳的货物数:%-5d\n",b); 

 printf("商丘的货物数:%-5d\n",c); 

 printf("濮阳的货物数:%-5d\n",d);

 printf("新乡的货物数:%-5d\n",e); 

 printf("周口的货物数:%-5d\n",f); 

 printf("信阳的货物数:%-5d\n",g);

}

void way(struct cargo stu[])

{

 int i,a=0,b=0,c=0,d=0,e=0;

    for(i=0;stu[i].weight!=0;i++)

    {

     if(stu[i].way=='s') a++;

  else if(stu[i].way=='r') b++; 

  else if(stu[i].way=='p') c++; 

  else if(stu[i].way=='w') d++; 

  else if(stu[i].way=='h') e++;

 }

 printf("航运的货物数:%-5d\n",a); 

 printf("铁路的货物数:%-5d\n",b); 

 printf("管道的货物数:%-5d\n",c); 

 printf("水运的货物数:%-5d\n",d); 

 printf("公路的货物数:%-5d\n",e);

}

你可能感兴趣的:(c语言,模块测试,经验分享,交通物流,学习)