| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 640 人关注过本帖
标题:想请大家帮我看看我的程序为什错了
只看楼主 加入收藏
上帝之女萱
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-6-20
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
想请大家帮我看看我的程序为什错了
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxsize 4
#define ok 1
#define error 0
typedef struct HXnode {
 char air_num[10];
 char Feijihao[10];
 char date[10];
 char end_place[10];
 int  total;
 int  left;
struct HXnode *next;
}HXGLnode;
 typedef struct KHnode{
 char name;
 char air_num[10];
 int seat_num;
 struct KHnode*next;
} KHnode;
 HXnode *head_HX();
 KHnode *head_KH();
 int CreatHX(HXnode **l);
 int CreatKH(KHnode **l);
 int insertHX(HXnode**p,char*air_num,char *Feijihao,char *date,char *end_place,int total,int left);
 int insertKH(KHnode **p,char *name,int seat_num,char air_num);
 HXnode *modefy_airline(HXnode *l,char *air_num);
int DP(HX *a,char*air_num,KHnode *c,char *name,int seat_num)
int QXDP(KHnode *c,KHnode *L,char *name,int seat_num);
int CXHX(HXnode *head);
int CXKH(KHnode *head);
void main()
{
 int p=2;
 KHnode *cus=head_KH();
 HXnode *air=head_HX();
 char name[20],air_num[20],mima[20],ch;
 char t[20]="liuyu";
 clrscr();
 creatHXGL(&air);
 creatKH(&cus);
 while(p==2)
{
  printf("\n  welcome to the airline system  !\n\n please choose:\n\n   ");
  printf("*******************************\n\n");
  printf("   1.DP         \n");
  printf("   2.QXDP         \n");
  printf("   3.CX        \n");
  printf("   4.EXIT          \n\n");
  printf("*********************\n\n");
  switch(ch=getch())
{
 case'1':{printf("\n********DP*****\n");
          printf("please intput a airline num:");
    scanf("%s",&air_num);
   printf("please intput your name:");
   scanf("%s",&name);
  DP(air,air_num,cus,name);getch();};break;
  case'2':{printf("\n********QXDP*****\n");
          printf("please intput  name:");
    scanf("%s",name);
    QXDP(cus,air,name);}:break;
    case'3':{printf("\n********CX*****\n");
             printf("1.CXHXIAN\n");
             printf("2.CXKH\n");
             printf(" other exit\n");
             printf("*************\n");
             if((ch=getch())=='1')
{
  ptintf("********CXHANGXIAN***********\n");
  CXHX(air);}
  else if(ch=='2')
 {
  printf("\n please intput the key:");
  scanf("%s",mima);
  if(strcmp(mima,t)==0)
  { printf("\n*******CXKH*******");
  CXKH(cus);}
  else printf("sorry,the key is wrong");getch();}}break;
  case'4':{getch();
  p=0;}
  break;}}}
  HXnode *head_HX()
  HXnode  *a;
  a=(HXnode *)malloc(sizeof(HXnode));
  if(a==NULL)
  a->next=NULL;
  return a;}
  KHnode *head_KH()
  {
   KHnode *c;
   c=(KHnode *)malloc(sizeof(KHnode));
   if(c==NULL)
   c->next=NULL;
   return c;}
  int CreatHX(HXnode **l)
  {HXnode *P=*l;
    int i=0;
   char*air_num[3]={"A111","B222","C333"} ;
   char *Feijihao[3]={"1021","1022","1023"};
   char *date[3]={"mon","mon","mon"};
   char *end_place={"tianjin","xiamen","dalian"};
   int total={50,50,50};
   int left={2,2,2};
  for(i=0;i<3;i++)
   insertHX(&p,air_num[i],date[i],end_place[i],total[i],left[i]);
   return ok;}
   int CreatKH(KHnode **l)
   KHnode *P=*l;
    int i=0;
    char *name[3]={"lili","liuli","wanli"};
     char * air_num={"A1021","A1022","A1023"};
    int seat_num[3]={2,1,1};
    for(i=0;i<3;i++)
    insertHK(&p,name[i],air_num[i],seat_num[i]);
    return ok;}
    int insertHX(HXnode **p,char*air_num,char *Feijihao,char *date,char *end_place,int total,int left)
    HXnode *q;
    q=(HXnode *)malloc(sizeof(HXnode));
    strcpy(q->air_num,air_num);
    strcpy(q->Feijihao,Feijihao);
    strcpy(q->date,date);
    strcpy(q->end_place,end_place);
    q->total=total;
    q->left=left;
    q->next=NULL;
    (*p)->next=q;
    (*p)=(*p)->next;
    return  ok;}
    int insertKH(KHnode **p,char *name,int seat_num)
    KHnode *q;
    q=(KHnode *)malloc(sizeof(KHnode));
    strcpy(q->name,name);
    q->seat_num;
    q->next=NULL;
    (*P)->next=q;
    (*p)=(*p)->next;
    return  ok;}
    HXnode *modefy_airline(HXnode *l,char *air_num)
   { HXnode  *p;
    p=l->next;
for(;p!=NULL;p=p->next)
{
 if(strcmp(air_num,p->air_num)==0)
{ p->left++;
return 1;}
printf("no the airline!");
 return 0;}}
 int DP(HXnode *a,char *air_num,KHnode *c,char *name,int seat_num)
{
 HXnode *p=a;
 KHnode *q=c->next;
 p=a->next;
for(;q->next!=NULL;q=q->next) ;
for(;p!=NULL;p=p->next)
{
  if(strcmp(p->air_num,air_num)==0){
  if(p->left>0)
{ printf("\nCHENG GONG DING PIAO\n\n   name:\n   seat_num:\n ");
  printf("\n***********");
  intsertKH(&q,name,air_num,p->total-p>left+1);
  p->left--;return ok;}
  else
{ printf("seat is full");
return  0;}}
 printf("\n");}
 int QXDP(KHnode *c,HXnode *l,char *name)
{
 KHnode *p,*pr;
char air_num[20];
pr=c;
p=pr->next;
while(p!=NULL)
{if (strcmp(p->name,name)==0)
{ strcmp(air_num,p->air_num);
l=modefy_airline(l,air_num);
pr->next=p->next;
p=pr->next;
printf("TUI PIAO CHENG GONG\n");
return ok;}pr=pr->next;
p=pr->next;}
printf("CUO WU\n ");
return error;}
int CXHX(HXnode *head)
 {HXnode *p=head->next;
printf("air_num  Feijihao   date    end_place  total   left\n\n");
for(;p!=NULL;p=p->next)
 { printf("%s","%10s","%9s\n",p->air_num,p->end_place,p->left);
   printf("\n");
return ok;}
int CXKH(KHnode *head)
{ struct KHnode *q=head->next;
printf("name  air_num\n\n");
for(;q!=NULL;q=q->next)
{printf("%s %s\n",q->nqme,q->num);
printf("\n");}
 printf("\n***************");
return  ok;}
搜索更多相关主题的帖子: next total include 
2012-06-20 22:45
上帝之女萱
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-6-20
收藏
得分:0 
我只是不想完全抄网页上,所以自己改动一下了,但是运行还是错了,所以请教各位!!!
2012-06-21 10:14
上帝之女萱
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-6-20
收藏
得分:0 
QXDP(cus,air,name);}:break这里运行之后提醒说可疑的指针转换main函数中,这是什么意思?怎么改?
2012-06-21 15:53
cuijunchao
Rank: 5Rank: 5
来 自:湖南桂东
等 级:职业侠客
威 望:3
帖 子:132
专家分:386
注 册:2012-4-4
收藏
得分:20 
编译程序都有自动检错的,自己学会看错,这么长的代码,没有谁会想看的.更别提看问题了.
2012-06-24 12:05
金峰
Rank: 1
等 级:新手上路
帖 子:5
专家分:4
注 册:2012-10-16
收藏
得分:0 
wokanbudong
2012-10-17 15:46
快速回复:想请大家帮我看看我的程序为什错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018053 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved