skip

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int n,num,i=0,a,b,c,d;
cout <<"Choose n to create a complete graph [3 9]? ";
cin >> n;
cout << "-------------------------------------------------------------------" <<endl;
cout << "verticles:";
for (num=1;num<=n;num++)
cout <<" "<<num << ", ";
cout << "=> Total: " << n <<endl;
cout << "Edges: ";
for (int a=1;a<n;a++)
for(int b=a+1;b<=n;b++){
cout << a<<"-"<<b <<" ";
i++;}
cout << "=> Total: " << i <<endl;
cout << "-------------------------------------------"<<endl;
cout << "All possible maximal matchings:"<<endl;
for (int a=1;a<n;a++)
for(int b=a+1;b<=n;b++)
for(int c=3;c<n;c++)
for(int d=c+1;d<=n;d++)
{cout << a<< "-"<< b<<","<<" "<<c<<"-"<<d<<endl;}
system("pause");
return 0;
}
can someone tell me that how can i skip those lines where the value of c/d=b.
You could use an if statement that only executes the lines when c/d != b.
Thank you very much,but how can my output be ?
1-2, 3-4
1-2, 3-5
1-2, 4-5
1-3, 2-4
1-3, 2-5
1-3, 4-5
1-4, 2-3
1-4, 2-5
1-4, 3-5
1-5, 2-3
1-5, 2-4
1-5, 3-4
2-3, 4-5
2-4, 3-5
2-5, 3-4
Topic archived. No new replies allowed.