Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GCF(int First, int Second)
- {
- int Dev1 = 0, Dev2 = 0;
- int LoopCount = 0, FUP = 0, SUP = 0;
- int FA[1000],SA[1000];
- //printf("Filling Arrays!\n");
- for(int F1 = 0; F1 < First; F1++)
- {
- FA[F1] = 0;
- }
- for(int S1 = 0; S1 < Second; S1++)
- {
- SA[S1] = 0;
- }
- //printf("Generating Compareable Numbers! \n");
- if(First > Second)
- {
- LoopCount = First;
- }
- else if(Second > First)
- {
- LoopCount = Second;
- }
- else if(First == Second)
- {
- LoopCount = First;
- }
- //printf("The LoopCount is : %d \n",LoopCount);
- //Generate Numbers For Arrays
- //gets all facotrs of both numbers
- for(int Go = 1; Go <= LoopCount; Go++ )
- {
- //printf("Loop Number : %d \n\n",Go);
- if(Go <= First)
- {
- Dev1 = (First / Go);
- if(IsWholeNumber(First, Go))
- {
- //printf("%d : %d \t",First, Dev1);
- FA[FUP] = Dev1;
- FUP++;
- }
- }
- if(Go <= Second)
- {
- Dev2 = (Second / Go);
- if(IsWholeNumber(Second, Go))
- {
- //printf("%d : %d \n\n",Second, Dev2);
- SA[SUP] = Dev2;
- SUP++;
- }
- }
- }
- //printf("End Of Number Generating!\n\n\n\n");
- //printf("Starting Comparison!\n");
- //Compare Numbers Of Arrays
- for(int F = 0; F < First; F++)
- {
- for(int S = 0; S < Second; S++)
- {
- if( (FA[F] == SA[S]) && (FA[F] != 0) && (SA[S] != 0) )
- {
- cout << First << " : "<< FA[F] << " " << Second << " : " << SA[S] << endl;
- }
- }
- }
- }
- //The whole number getting system that goes with this.
- bool IsWholeNumber(int TestNum, int DividedBy)
- {
- int EndResult = 0, Quotient = 0;
- Quotient = TestNum / DividedBy;
- EndResult = Quotient * DividedBy;
- if(EndResult == TestNum)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement