-
大小: 0.01M文件類型: .cpp金幣: 1下載: 0 次發布日期: 2021-02-01
- 標簽: 數據結構??
資源簡介
代碼片段和文件信息
#include
#include?
typedef?struct?glnode
{
char?name[100];????????????????????????????????????????//教師或者學生的姓名
char?prof[100];????????????????????????????????????????//教師結點表示職稱,學生結點表示班級
int?type;??????????????????????????????????????????????//結點類型:0-教師,1-研究生,2-本科生
struct?{struct?glnode?*hp*tp;}ptr;?????????????????????//*hp指向同級的下一個結點,tp指向下級的首結點
}glist;
?//建立廣義表
glist?*glistcreate(char?*str)
{
????glist?*head*p*q*m*a;?????????????????????????????????//簡要介紹:head指向頭節點,不變;p指向導師結點;q指向研究生結點;a指向本科生結點;m指向新創建的結點
????int?i=0j=0flag=0flag1=0flag2=0len=strlen(str);
????head=p=q=m=a=NULL;
????while(i ????{
????????if(str[i]==‘)‘||str[i]==‘(‘||str[i]==‘‘||str[i]==‘)‘||str[i]==‘(‘||str[i]==‘‘)
????????{
????????????i++;
????????????continue;
????????}
????????else
????????{
????????????if(!(m=(glist?*)malloc(sizeof(glist))))
????????????????exit(1);
????????????for(j=0;str[i]!=‘-‘;)????????????????????????//將字符串中的學生信息轉化成學生結點
- 上一篇:蛇形矩陣源碼(c語言)
- 下一篇:經典編程100題答案.rar
評論
共有 條評論