{#include
using namespace std;
struct Rect{
int width;
int height;
int area;
Rect *next;
};
Rect *head;
Rect* getNode();
void Create(){
if((head=getNode())==NULL)
return;
for(Rect *pE=head, *pS; pS=getNode(); pE=pS)
pE->next=pS;
}
int main()
{
Rect *temp;
Create();
if(head==NULL)
return -1;
for(Rect* p=head; p;)
{
cout<<p->width*p->height<<endl;
temp=p;
p=p->next;
delete temp;
}
return 0;
}// 在此处补充你的代码
}
供参考:
#include <iostream>
using namespace std;
struct Rect{
int width;
int height;
int area;
Rect *next;
};
Rect* head;
Rect* getNode();
void Create()
{
if((head=getNode())==NULL)
return;
for(Rect *pE=head, *pS; pS=getNode(); pE=pS)
pE->next=pS;
}
int main()
{
Rect *temp;
Create();
if(head==NULL)
return -1;
for(Rect* p=head; p;)
{
cout<<p->width*p->height<<endl;
temp=p;
p=p->next;
delete temp;
}
return 0;
}
// 在此处补充你的代码
Rect* getNode()
{
Rect *p = new Rect;
if(!p) return NULL;
p->next = NULL;
cin>>p->width>>p->height;
p->area = p->width*p->height;
if(p->width == 0 && p->height == 0){ //输入 0 0 时,结束输入。
delete p;
p = NULL;
}
return p;
}