Spate
سه شنبه 10 بهمن 1391, 12:13 عصر
سلام دوستان
کد زیر در هنگام کامپایل ارور میده!
لطفاَ راهنمایی کنید.
ممنون
#include<iostream.h>
#include<conio.h>
#define MAX 10
int *Vcolor,n,m;
int w[MAX][MAX]={0};
bool promising(int);
void m_coloring(int i)
{
int color;
if(promising(i))
if(i==n)
{
for(int index=1;index<=n;index++)
cout<<Vcolor[index]<<" ";
cout<<endl;
}
else
for(color=1;color<=m;color++)
{
Vcolor[i+1]=color;
m_coloring(i+1);
}
}
bool promising(int i)
{
int k;
bool myswitch;
k=1;
myswitch = true;
while (k<i && myswitch)
{
if(w[i][k] && Vcolor[i]==Vcolor[k])
myswitch = false;
k++;
}
return myswitch;
}
void main()
{
cout<<"Enter Number Of Vertices:\n";
cin>>n;
cout<<"Enter Number Of Color (m):\n";
cin>>m;
Vcolor=new int[m+1];
cout<<"Enter Your Graph Using Weight Matrix 1 If Exciting Edge And Else 0\n";
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
if((i!=j)&&(i<j))
{
cout<<i<<" and "<<j<<" : ";
cin>>w[i][j];
w[j][i]=w[i][j];
}
if(i==j)
w[i][j]=0;
}
cout<<"\nOutput\n\n";
m_coloring(0);
cout<<"\nPress Any Key...\n";
getch();
}
کد زیر در هنگام کامپایل ارور میده!
لطفاَ راهنمایی کنید.
ممنون
#include<iostream.h>
#include<conio.h>
#define MAX 10
int *Vcolor,n,m;
int w[MAX][MAX]={0};
bool promising(int);
void m_coloring(int i)
{
int color;
if(promising(i))
if(i==n)
{
for(int index=1;index<=n;index++)
cout<<Vcolor[index]<<" ";
cout<<endl;
}
else
for(color=1;color<=m;color++)
{
Vcolor[i+1]=color;
m_coloring(i+1);
}
}
bool promising(int i)
{
int k;
bool myswitch;
k=1;
myswitch = true;
while (k<i && myswitch)
{
if(w[i][k] && Vcolor[i]==Vcolor[k])
myswitch = false;
k++;
}
return myswitch;
}
void main()
{
cout<<"Enter Number Of Vertices:\n";
cin>>n;
cout<<"Enter Number Of Color (m):\n";
cin>>m;
Vcolor=new int[m+1];
cout<<"Enter Your Graph Using Weight Matrix 1 If Exciting Edge And Else 0\n";
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
if((i!=j)&&(i<j))
{
cout<<i<<" and "<<j<<" : ";
cin>>w[i][j];
w[j][i]=w[i][j];
}
if(i==j)
w[i][j]=0;
}
cout<<"\nOutput\n\n";
m_coloring(0);
cout<<"\nPress Any Key...\n";
getch();
}