CS计算机代考程序代写 #include

#include

int countMainlandNorth();
int countMainlandSouth();
int countCapeBretonIsland();

int Annapolis, Antigonish, Cape_Breton, Colchester, Cumberland, Digby, Guysborough, Halifax, Hants;
int Inverness, Kings, Lunenburg, Pictou, Queens, Richmond, Shelburne, Victoria, Yarmouth;

int main() {
int counter = 0;

for (Hants = 0; Hants < 3; Hants++) { for (Lunenburg = 0; Lunenburg < 3; Lunenburg++) { if (Lunenburg != Hants) { counter += countMainlandNorth() * countMainlandSouth(); } } } counter *= countCapeBretonIsland(); printf("There are %i 3-colourings of Nova Scotia.\n", counter); return(0); } int countMainlandNorth() { int counterMainlandNorth = 0; for (Antigonish = 0; Antigonish < 3; Antigonish++) { for (Colchester = 0; Colchester < 3; Colchester++) { if (Colchester != Hants) { for (Cumberland = 0; Cumberland < 3; Cumberland++) { if (Cumberland != Colchester) { for (Guysborough = 0; Guysborough < 3; Guysborough++) { if (Guysborough != Antigonish) { for (Halifax = 0; Halifax < 3; Halifax++) { if (Halifax != Colchester && Halifax != Guysborough && Halifax != Hants && Halifax != Lunenburg) { for (Pictou = 0; Pictou < 3; Pictou++) { if (Pictou != Antigonish && Pictou != Colchester && Pictou != Guysborough) { counterMainlandNorth++; } } } } } } } } } } } return(counterMainlandNorth); } int countMainlandSouth() { int counterMainlandSouth = 0; for (Annapolis = 0; Annapolis < 3; Annapolis++) { if (Annapolis != Lunenburg) { for (Digby = 0; Digby < 3; Digby++) { if (Digby != Annapolis) { for (Kings = 0; Kings < 3; Kings++) { if (Kings != Annapolis && Kings != Hants && Kings != Lunenburg) { for (Queens = 0; Queens < 3; Queens++) { if (Queens != Annapolis && Queens != Digby && Queens != Lunenburg) { for (Shelburne = 0; Shelburne < 3; Shelburne++) { if (Shelburne != Queens) { for (Yarmouth = 0; Yarmouth < 3; Yarmouth++) { if (Yarmouth != Digby && Yarmouth != Shelburne) { counterMainlandSouth++; } } } } } } } } } } } } return(counterMainlandSouth); } int countCapeBretonIsland() { int counterCapeBretonIsland = 0; for (Cape_Breton = 0; Cape_Breton < 3; Cape_Breton++) { for (Inverness = 0; Inverness < 3; Inverness++) { for (Richmond = 0; Richmond < 3; Richmond++) { if (Richmond != Cape_Breton && Richmond != Inverness) { for (Victoria = 0; Victoria < 3; Victoria++) { if (Victoria != Cape_Breton && Victoria != Inverness) { counterCapeBretonIsland++; } } } } } } return(counterCapeBretonIsland); }