链表思想

#include <stdio.h>

int main()

/*

fridge=0:代表没有冰箱

washMachine=0:没有洗衣机

*/

struct home

{

int fridge;

int washMachine;

struct home *p;

};

int main(){

struct home liHome,tongHome,huHome;

liHome.fridge=1;

liHome.washMachine=0;

liHome.p=&tongHome;

tongHome.fridge=0;

tongHome.washMachine=1;

tongHome.p=&huHome;

huHome.fridge=1;

huHome.washMachine=1;

huHome.p=NULL;

struct home *temp=&liHome;

for (; temp!=NULL; temp=temp->p)

{

printf("冰箱=%d,洗衣机=%d\n",temp->fridge,temp->washMachine);

}

/*

struct home *pLi=&liHome;

//小李家

printf("小李家冰箱=%d,洗衣机=%d\n",pLi->fridge,pLi->washMachine);

struct home *pTong=pLi->p;

//童歌家    printf("童歌家冰箱=%d,洗衣机=%d\n",pTong->fridge,pTong->washMachine);

struct home *pHu=pTong->p;

printf("胡歌家冰箱=%d,洗衣机=%d\n",pHu->fridge,pHu->washMachine);

*/

return 0;

}


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容