| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 426 人关注过本帖
标题:求助:有关三个方向的十字链表,请高手检查测试出现的错误
只看楼主 加入收藏
grace9076
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-8-11
收藏
 问题点数:0 回复次数:0 
求助:有关三个方向的十字链表,请高手检查测试出现的错误
这是我写的三个方向的十字链表的录入函数(我所做的信息系统的一部分)。但在测试时出现了一些问题,不知道为什么。请高手指点。谢谢~~
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>

char buf[16*10*2],buf1[16*2],buf2[20*5],buf3[35*10],buf4[30*3],buf5[30*5],buf6[50*5];

typedef struct biao3{
char bianhao[12];
char baodaoriqi[10];
char meitileibie;
char meitimingchen[20];
char neirongsuoying[50];
struct biao3 *next3;
}media;

typedef struct biao2{
char bianhao[12];
char shijian[15];
char leixing[10];
char dengji;
char shengfen[8];
char danwei[20];
int siwangshu;
int zhongshangshu;
float jingjisunshi;
struct biao2 *next2;
struct biao3 *head2;
}infor;

typedef struct biao1{
char shengfen[8];
char fuzeren[15];
char dianhua[15];
struct biao1 *next1;
struct biao2 *head1;
}jianguan;


unsigned short int State=0;
unsigned int count[4]={0,0,0,0};
char filename[32]="";
FILE *fp=NULL;
jianguan *head=NULL,*p=NULL;

void box(int startx,int starty,int high,int width)
/*用以画黄色的边框,xy表示方框左上角坐标,high为高度,width为宽度*/
{
    int i;
    gotoxy(startx,starty);
    textcolor(YELLOW);
    putch(0xda);
    for (i=startx+1;i<width;i++)
    putch(0xc4);
    putch(0xbf);
    for( i=starty+1;i<high;i++)
    {
        gotoxy(startx,i);
        putch(0xb3);
        gotoxy(width,i);
        putch(0xb3);
    }
    gotoxy(startx,high);
    putch(0xc0);
    for (i=startx+1;i<width;i++)
        putch(0xc4);
    putch(0xd9);
    textcolor(BLACK);
}


void creat_cross_list (void)
{
char ch;
jianguan *hp = NULL,*pjianguan,*head0;
infor *pinfor;
media *pmedia;

loop:
pjianguan= (jianguan *)malloc(sizeof(jianguan)); /*创建新的省份监管信息表*/
gettext(30,10,50,15,buf2);
    window(30,10,50,15);
    textbackground(LIGHTGRAY);
    textcolor(BLACK);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Shengfen");
    box(2,3,5,20);
    gotoxy(3,4);
    scanf("%s", pjianguan->shengfen);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Fuzeren ");
    box(2,3,5,20);
    gotoxy(3,4);
    scanf("%s", pjianguan->fuzeren);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Dianhua ");
    box(2,3,5,20);
    gotoxy(3,4);
    scanf("%s", pjianguan->dianhua);
    clrscr();
puttext(30,10,50,15,buf2);
pjianguan->head1=NULL;/*建立后进先出链表*/
pjianguan->next1=hp;
hp=pjianguan;
    head0=hp;
    p=hp;

loop1:
pinfor=(infor *)malloc(sizeof(infor));/*创建新的安全事故信息表*/
gettext(20,10,50,15,buf5);
    window(20,10,50,15);
    textbackground(LIGHTGRAY);
    textcolor(BLACK);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Bianhao ");
    box(2,3,5,30);
    gotoxy(3,4);
    scanf("%s", pinfor->bianhao);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Shijian ");
    box(2,3,5,30);
    gotoxy(3,4);
    scanf("%s", pinfor->shijian);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Leixing ");
    box(2,3,5,30);
    gotoxy(3,4);
    scanf("%s", pinfor->leixing);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Dengji ");
    box(2,3,5,30);
    gotoxy(3,4);
    scanf("%c",&pinfor->dengji);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Danwei ");
    box(2,3,5,30);
    gotoxy(3,4);
    scanf("%s",pinfor->danwei);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Siwangshu ");
    box(2,3,5,30);
    gotoxy(3,4);
    scanf("%d",&pinfor->siwangshu);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Zhongshangshu");
    box(2,3,5,30);
    gotoxy(3,4);
    scanf("%d",&pinfor->zhongshangshu);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Jingjisunshi ");
    box(2,3,5,30);
    gotoxy(3,4);
    scanf("%f",&pinfor->jingjisunshi);
    clrscr();
puttext(20,10,50,15,buf5);
strcpy(pinfor->shengfen,pjianguan->shengfen);
pinfor->head2=NULL;/*建立后进先出链表*/
pinfor->next2=head0->head1;
head0->head1=pinfor;

loop2:
    pmedia=(media *)malloc(sizeof(media)); /*创建新的媒体报道信息表*/
gettext(10,10,60,15,buf6);
    window(10,10,60,15);
    textbackground(LIGHTGRAY);
    textcolor(BLACK);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Baodaoriqi ");
    box(2,3,5,50);
    gotoxy(3,4);
    scanf("%s",pmedia->baodaoriqi);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Meitileibie ");
    box(2,3,5,50);
    gotoxy(3,4);
    scanf("%c",&pmedia->meitileibie);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Meitimingchen ");
    box(2,3,5,50);
    gotoxy(3,4);
    scanf("%s",pmedia->meitimingchen);
    clrscr();
    gotoxy(2,2);
    cprintf("Enter Neirongsuoying");
    box(2,3,5,50);
    gotoxy(3,4);
    scanf("%s",pmedia->neirongsuoying);
    clrscr();
puttext(10,10,60,15,buf6);

    strcpy(pmedia->bianhao,pinfor->bianhao);
    pmedia->next3=head0->head1->head2;/*建立后进先出链表*/
head0->head1->head2=pmedia;

gettext(10,10,60,15,buf6);
    window(10,10,60,15);
    textbackground(LIGHTGRAY);
    textcolor(BLACK);
    clrscr();
    gotoxy(2,2);
    cprintf("Do you also want to continue to enter media information ?");
    box(2,3,5,50);
    gotoxy(3,4);
    scanf("%c",&ch);
    clrscr();
puttext(10,10,60,15,buf6);
if  (ch=='y'||ch=='Y')
goto loop2;

gettext(10,10,60,15,buf6);
    window(10,10,60,15);
    textbackground(LIGHTGRAY);
    textcolor(BLACK);
    clrscr();
    gotoxy(2,2);
    cprintf("Do you also want to continue to import safety accident information ?");
    box(2,3,5,50);
    gotoxy(3,4);
    scanf("%c",&ch);
    clrscr();
puttext(10,10,60,15,buf6);
if  (ch=='y'||ch=='Y')
goto loop1;

gettext(10,10,60,15,buf6);
    window(10,10,60,15);
    textbackground(LIGHTGRAY);
    textcolor(BLACK);
    clrscr();
    gotoxy(2,2);
cprintf("Do you also want to continue to enter the provinces regulatory information ?");
    box(2,3,5,50);
    gotoxy(3,4);
    scanf("%c",&ch);
    clrscr();
    puttext(10,10,60,15,buf6);
if  (ch=='y'||ch=='Y')
goto loop;


free(pjianguan);
free(pinfor);
free(pmedia);
free(hp);
}/*利用三重循环分别输入某省份监管信息和所属安全事故基本信息及其媒体报道信息*/


main()
{
    creat_cross_list();
}
搜索更多相关主题的帖子: 检查 字链 
2010-08-22 22:41
快速回复:求助:有关三个方向的十字链表,请高手检查测试出现的错误
数据加载中...
 
   



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

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