| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 533 人关注过本帖
标题:[求助]为什么是死循环-->purana转移-->feng1256转移
取消只看楼主 加入收藏
swr88
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-5-7
收藏
 问题点数:0 回复次数:0 
[求助]为什么是死循环-->purana转移-->feng1256转移

#include <iostream>
#include <string>
using namespace std;
typedef struct node
{
int number;
int password;
struct node *next;
}SLink;

int GetLength(SLink *sq)
{

int i=1;
SLink *p=sq->next;
while(p!=sq)
{
i++;p=p->next;
}
return i;
}

int DelElem(SLink *sq,int i)
{
int j=1;
SLink *p=sq,*q;
if(i<1 || i>GetLength(sq))
return 0;
else if(i==1)
{
if(GetLength(sq)==1)
{q=sq;free(q);
sq=NULL;}
else
{
while(j<GetLength(sq))
{
p=p->next;j++;
}
q=sq;
p->next=q->next;
sq=q->next;
free(q);
return 1;
}
}
else
{
while(j<i-1)
{
p=p->next;j++;
}
q=p->next;
p->next=q->next;
free(q);
return 1;
}
}


void main()
{
int n;
cout << "n=";
cin >> n;
int m;
cout <<"m=";
cin >> m;

SLink *sq ;
SLink *people = (SLink *)malloc(sizeof(SLink));
people->number=1;
cout << "people->password=" ;
cin >> people->password;
people->next=people;
SLink *lq =people;

for(int i=1;i<n;i++)
{
sq =(SLink *)malloc(sizeof(SLink));
sq->number =i+1;
cout <<"sq->password=";
cin >> sq->password;
lq->next =sq;
sq->next =people;
lq = sq;
}

DelElem(people,1);
for(sq=people;sq->next!=people;sq=sq->next)
{

cout << sq->number;

//cout << sq->next;
}
cout << sq->number;
}
哪位高手能帮帮我为什么是死循环

搜索更多相关主题的帖子: purana 
2006-05-07 21:36
快速回复:[求助]为什么是死循环-->purana转移-->feng1256转移
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011304 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved