正文

asdadadada2008-06-28 11:11:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/19880128/36332.html

分享到:

#include "stdio.h"#include "stdlib.h"#include "string.h"typedef struct Node{ char name[10]; int x,y; struct Node *next;}Node,*Linklist;void main(){ void checkname(Node *L); void checklocation(Node *L); struct Node *L,*temp; char nametemp[10]; int xtmp=0,ytmp=0; int flag=1,check; L=(Linklist)malloc(sizeof(Node)); (*L).next=NULL; temp=(Linklist)malloc(sizeof(Node)); (*temp).next=NULL; while(flag) {  printf("Please input the cities' name:  ");  scanf("%s",&nametemp);  printf("Please input the location:   ");  scanf("%d%d",&xtmp,&ytmp);  if(xtmp!=0&&strlen(nametemp)<10)  {   temp=(Node*)malloc(sizeof(Node));   strcpy(temp->name,nametemp);   temp->x=xtmp;   temp->y=ytmp;   temp->next=L->next;   L->next=temp;  }  else   flag=0; } printf("Please select the service.   1.Find location by name.   2.Find name by location."); scanf("%d",&check); switch(check) { case 1:  checkname(L); }}////////////////////////////////////由名字找位置//////////////////////////////////void checkname(Node *L){ char sname[10]; printf("Please input the name:  ");    scanf("%s",&sname); printf("Name:%s. Location:%d %d",&sname,&(*L).x,&(*L).y); while(L!=NULL) {         L=L->next; }}

阅读(957) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册