Ktoś wie czemu przestaje działac po podaniu wartości?
#include<iostream>
#include<ctime>
#include<fstream>
using namespace std;
struct nodes;
struct adj
{
int ndnm;
int nmed;
nodes *next;
};
struct nodes
{
int ndnm;
int edln;
nodes *next;
};
int edc=0;
int randomed(int a,int b);
void checknd(nodes *t,adj *list,int u, int v, int edlength);
void disp(adj *list,int n);
int main()
{
cout<<"\nPodaj liczbę wezlow ... :";
int n;
cin>>n;
adj *list=new adj[n+1];
int i=0;
for(i=0;i<=n;i++)
{
list[i].ndnm=i;
list[i].nmed=0;
list[i].next=NULL;
}
cout<<"Stworzono formację sasiedztwa.\n";
int n1,n2;
cout<<"\nWprowadz limit dlugosci krawedzi :\n";
cout<<"\nPodaj dolna granice :";
cin>>n1;
cout<<"\nPodgaj gorna granice:";
cin>>n2;
int count=0,edlength;
int u=0,v=0;
nodes *temp,*temp2;
while(edc!=n)
{
u=rand()%n+1;
v=rand()%n+1;
if(u!=v)
{
if(list[u].nmed<7 && list[v].nmed<7)
{
edlength=randomed(n1,n2);
if(list[u].nmed==0)
{
list[u].next=new nodes;
temp=list[u].next;
temp->ndnm=v;
temp->edln=edlength;
temp->next=NULL;
list[u].nmed++;
}
else
{
checknd(list[u].next,list,u,v,edlength);
}
if(list[v].nmed==0)
{
list[v].next=new nodes;
temp2=list[v].next;
temp2->ndnm=u;
temp2->edln=edlength;
temp2->next=NULL;
list[v].nmed++;
}
else
{
checknd(list[v].next,list,v,u,edlength);
}
}
}
}
disp(list,n);
cin.ignore();
return 0;
}
int randomed(int a, int b)
{
return (a+rand()%(b-a)+1);
}
void checknd(nodes *t,adj *list,int u,int v,int edlength)
{
int flag=0;
nodes *t2;
do
{
if(t->ndnm==v)
{
flag=1;
}
if(t->next==NULL)
t2=t;
t=t->next;
}
while(t!=NULL);
t=t2;
if(flag==0)
{
t->next=new nodes;
t=t->next;
t->next=NULL;
t->ndnm=v;
list[u].nmed++;
if(list[u].nmed==3)
{
edc++;
}
t->edln=edlength;
}
}
void disp(adj *list, int n)
{
int i=0;
nodes *temp;
for(i=1;i<=n;i++)
{
temp=list[i].next;
do
{
temp=temp->next;
}
while(temp);
}
}