Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- typedef unsigned int Uint;
- using namespace std;
- int main (int argc, char * const argv[])
- {
- double T2;
- double maxValue;
- double T1;
- // insert code here...
- cout << "\nEntering\nEnter Max Value : ";
- cin >> maxValue;
- cout << "\nEnter Start Value : ";
- cin >> T1;
- cout << "\nEnter Second Value: ";
- cin >> T2;
- double ratio = T2/T1;
- while(1)
- {
- for(Uint Tn = 1;;++Tn)
- {
- if(maxValue > T1)
- {
- if(T1*pow((ratio), (double) Tn) > maxValue)
- {
- cout << "\n*--------------*\nFound it: n is " << Tn << "\n\n";
- break;
- }
- }
- else
- {
- if(T1*pow((ratio), (double) Tn) < maxValue)
- {
- cout << "\n*--------------*\nFound it: n is " << Tn << "\n\n";
- break;
- }
- }
- }
- cout << "\nDo new calc? ";
- char result;
- cin >> result;
- if(result == 'q')
- return 1;
- //otherwise
- cout << "\nEnter Start Value : ";
- cin >> T1;
- cout << "\nEnter Second Value: ";
- cin >> T2;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment