求助!!!
#include<stdio.h>#include<stdlib.h>
struct MyNode
{
int num;
int lay;
int sort;
struct MyNode *pNext;
};
int main()
{
printf("输入信息\n");
int n,a,b,c;
scanf("%d,%d,%d,%d",&n,&a,&b,&c);
struct MyNode*pNode =(struct MyNode *)malloc(n*sizeof(MyNode));
int i;
for(i=0;i<n;i++)
{
pNode.num=i+1;
pNode.lay=0;
pNode.sort=0;
pNode.pNext=NULL;
}
for(i=0;i<n;i++)
{
int j=i;
while(j)
{
if(pNode.num%i==0)
{
pNode.lay=pNode.lay+1;
break;
}
j--;
}
}
int lay=0;
for(i=0;i<n,i++)
{
if(pNode.lay>lay)
lay=pNode.lay;
}
struct MyNode **play= (struct MyNode**)malloc(lay*sizeof(MyNode*));
for(int j=0;j<=lay;i++)
{
struct MyNode*pTemp=NULL;
int k=0;
for(int i=0;i<n;i++)
{
if(k==0)
{
if(pNode.lay==j)
{
play=&pNode;
pTemp=play;
k=1;
}
}
else
if(pNode.lay==j)
{
pTemp->pNext=&pNode;
pTemp=pTemp->pNext;
}
}
}
struct MyNode*ptemp=NULL;
for(i=0;i<=lay;i++)
{
ptemp=play;
while(ptemp!=NULL)
{
printf("%5d",ptemp->num);
ptemp=ptemp->pNext;
}
printf("\n");
}
struct MyNode*pHead=play;
for(i+0;i<lay;i++)
{
while(play->pNext!=NULL)
{
play=play->pNext;
}
play->pNext=play;
}
int num=1;
ptemp=pHead;
while(ptemp!=NULL)
{
if(ptemp->num==a)
d=ptemp->sort;
if(ptemp->num==b)
e=ptemp->sort;
if(ptemp->num==c)
f=ptemp->sort;
ptemp=ptemp->pNext;
}
printf("输入排名:%d,%d,%d\n",d,e,f);
return 0;
}
图片中的错误是为什么啊?哪位大佬可以给我解答一下?
sizeof(structMyNode)
页:
[1]