From 4c3a07daba03debe294376cba07968f078719a87 Mon Sep 17 00:00:00 2001 From: Ayushi C <67193440+AyushiChakrabarty@users.noreply.github.com> Date: Wed, 4 Nov 2020 11:30:44 +0530 Subject: [PATCH] Create Gayle-Shapley_Modified --- Gayle-Shapley_Modified | 115 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 Gayle-Shapley_Modified diff --git a/Gayle-Shapley_Modified b/Gayle-Shapley_Modified new file mode 100644 index 0000000..c947acc --- /dev/null +++ b/Gayle-Shapley_Modified @@ -0,0 +1,115 @@ +//Stable matching problem +// Consider a town with n men and n women seeking to get married to one +// another. Each man has a preference list that ranks all the women, and each +// woman has a preference list that ranks all the men. +// The set of all 2n people is divided into two categories: good people and +// bad people. Suppose that for some number k, 1≤ k ≤ n − 1, there are k good +// men and k good women; thus there are n − k bad men and n − k bad women. +// Everyone would rather marry any good person than any bad person. +// Formally, each preference list has the property that it ranks each good person +// of the opposite gender higher than each bad person of the opposite gender: its +// first k entries are the good people (of the opposite gender) in some order, and +// its next n − k are the bad people (of the opposite gender) in some order. +// Show that in every stable matching, every good man is married to a good woman. + +#include +#include +using namespace std; +#define total 100 + +int n; +int wom_p[total][total], man_p[total][total]; +int match[total], watch[total], single[total]; + +//Finding a stable match +void stable_marriage() +{ + int m,w; + int flag=1; + + for(m=0; m>t; + + while(t--) + { + cout<<"Enter the total no. of men and women: "; + cin>>n; + cout<<"Enter till what index we have good women and men:"; + cin>>k; + for(i=0; i>l; + for(j=0; j>pref; + man_p[l-1][pref-1]=j; + } + } + + for(i=0; i>m; + for(j=0; j>pref; + wom_p[m-1][j] = pref-1; + } + } + + stable_marriage(); + + //Displaying the matches + cout<<"The stable matches are:"<