?? zhanming.cpp
字號:
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
struct station
{
char name[8];
struct station *nextSta;
};
struct station *creat_sta(struct station *h);
void print_sta(struct station *h);
int num=0;
main()
{
struct station *head;
head=NULL;
printf("please input station name:\n");
head=creat_sta(head);
printf("------------------------\n");
printf("Number of station = %d\n",num);
print_sta(head);
getch();
}
struct station *creat_sta(struct station *h)
{
struct station *p1, *p2;
p1=p2=(struct station *)malloc(sizeof(struct station));
if(p2!=NULL)
{
scanf("%s",&p2->name);
p2->nextSta= NULL;
}
while(p2->name[0]!='#')
{
num++;
if(h==NULL)
h=p2;
else
p1->nextSta=p2;
p1=p2;
p2=(struct station *)malloc(sizeof(struct station));
if(p2!=NULL)
{
scanf("%s",&p2->name);
p2->nextSta=NULL;
}
}
return h;
}
void print_sta(struct station *h)
{
struct station *temp;
temp=h;
while(temp!=NULL)
{
printf("%-8s",temp->name);
temp=temp->nextSta;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -