实时监控报警系统源代码——shiyuanwang

#include
#include
#include
#include
#include
typedef struct node
{
char time[20];
char neirong[40];
int bianhao;
struct node *next;
}node;
typedef struct jilu
{
char time[20];
char neirong[40];
int bianhao;
struct jilu *next;

}jilu;
void chushihua(node *l)
{
char flag='y';
node *p,*q;
p=l;
while(flag=='y')
{
q=(node*)malloc(sizeof(node));
printf("报警编号:\n");
scanf("%d",&q->bianhao);
fflush(stdin);
printf("请输入报警时间:\n");
gets(q->time);
printf("请输入报警内容:\n");
fflush(stdin);
gets(q->neirong);
p->next=q;
p=q;
printf("是否继续录入报警信息:\n");
fflush(stdin);
scanf("%c",&flag);
}
p->next=NULL;
}
void display(node *l)
{
node *p;
p=l->next;
while(p!=NULL)
{
printf("报警编号:%d",p->bianhao);
printf("报警信息:%s",p->neirong);
printf("报警时间:%s\n",p->time);
p=p->next;
}
}
void chujing(node *l,jilu *k)
{
node *p; node *j;
int i;
int flag=1;
jilu *q,*r;
p=l->next;
r=k;

printf("请输入你要出哪个警:\n");
scanf("%d",&i);
while(p!=NULL&&flag==1)
{
if(p->bianhao==i)
{
q=(jilu*)malloc(sizeof(jilu));
q->bianhao=p->bianhao;
strcpy(q->neirong,p->neirong);
strcpy(q->time,p->time);
r->next=q;
r=q;
r->next=NULL;
flag=0;
if(p=l->next)
l->next=p->next;
else
j->next=p->next;
free(p);
}
else
{
j=p;
p=p->next;
}
}
if(flag==1)
printf("无该报警信息\n");

}
void charu(node *l)
{
node *p,*q; char flag='y'; node *i;
int count=0;
p=l;

while(p->next!=NULL)
p=p->next;


while(flag=='y')
{
q=(node*)malloc(sizeof(node));
printf("报警编号:\n");
scanf("%d",&q->bianhao);
fflush(stdin);
printf("请输入报警时间:\n");
gets(q->time);
fflush(stdin);
printf("请输入报警内容:\n");
gets(q->neirong);

p->next=q;
p=q;
printf("是否继续录入报警信息:\n");
scanf("%c",&flag);
}
p->next=NULL;

i=l;
while(i->next!=NULL)
{
count++;
i=i->next;
}
if(count>10)
{
printf("有很多警待出\n");
}

}
void xianshichujing(jilu *k)
{
jilu *p;
p=k->next;
if(p=NULL)
printf("还未出警\n");
while(p!=NULL)
{
printf("报警编号:%d",p->bianhao);
printf("报警信息:%s",p->neirong);
printf("报警时间:%s\n",p->time);
p=p->next;
}

}
void main()
{
node *l;
int i,j;
jilu *k;
l=(node *)malloc(sizeof(node));
k=(jilu *)malloc(sizeof(jilu));
l->next=NULL;
k->next=NULL;
for(i=0;i<6;i++)
{
Sleep(1000);
printf(" sos ");
}
printf("初始化报警信息:\n");
chushihua(l);
display(l);

while(1)
{
printf("1:出警系统启动\n");
printf("2:出警信息显示\n");
printf("3:显示报警信息\n");
printf("4:新的报警系统\n");
printf("5:结束\n");
fflush

(stdin);
scanf("%d",&j);
switch(j)
{
case 1:
chujing(l,k);
break;
case 2:
xianshichujing(k);
break;
case 3:
display(l);
break;
case 4:
charu(l);
break;
case 5:
exit(0);
break;
default:
printf("error");
}
}



}

相关文档
最新文档