From: Christoph Fuerst Date: Sun, 26 Mar 2017 18:22:33 +0000 (+0200) Subject: Added menu dialog X-Git-Url: http://git.risc.jku.at/gitweb/?a=commitdiff_plain;h=290ced42d1314ef3cc299dc0f7c5473a267599e8;p=cfuerst%2Fformal-numbers.git Added menu dialog --- diff --git a/src/primefactors.cpp b/src/primefactors.cpp index 7de4e33..45a1498 100644 --- a/src/primefactors.cpp +++ b/src/primefactors.cpp @@ -100,45 +100,78 @@ void factor_int2(mpz_class N) cout << "Found prime-factors: " << (a-b)/2 << " and " << ((a+b-2)/2) << endl; } -int main() +int main(int argc, char** argv) { - mpz_class N; - mpz_class *trialdivisors, *factors; - unsigned long max; - unsigned long nooffactors; - - cout << "Enter Integer to be factored.... "; - cin >> N; - cout << endl; - - max = (unsigned long)(sqrt(N.get_ui())); - - trialdivisors = new mpz_class[max]; - factors = new mpz_class[max]; - - trialdivisors[0] = 2; - trialdivisors[1] = 3; - trialdivisors[2] = 5; - for(unsigned int i=3;i> input; + cout << endl; + }while((input != 'A') && (input != 'C') ); + + switch(input) + { + case 'A': + { + cout << "Select Trial divison" << endl; + mpz_class N; + mpz_class *trialdivisors, *factors; + unsigned long max; + unsigned long nooffactors; + + cout << "Enter Integer to be factored.... "; + cin >> N; + cout << endl; + + max = (unsigned long)(sqrt(N.get_ui())); + + trialdivisors = new mpz_class[max]; + factors = new mpz_class[max]; + + trialdivisors[0] = 2; + trialdivisors[1] = 3; + trialdivisors[2] = 5; + for(unsigned int i=3;i> N; + cout << endl; + factor_int2(N); + break; + } + default: + break; + } } - factor_int(N, trialdivisors, nooffactors, factors); - - for(unsigned long i=0;i<=nooffactors;i++) - cout << factors[i] << " "; - cout << endl; - - factor_int2(N); - return (0); }