Guest User

Untitled

a guest
May 6th, 2012
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. typedef unsigned int Uint;
  5.  
  6. using namespace std;
  7.  
  8.  
  9. int main (int argc, char * const argv[])
  10. {
  11. double T2;
  12. double maxValue;
  13. double T1;
  14. // insert code here...
  15.  
  16. cout << "\nEntering\nEnter Max Value : ";
  17. cin >> maxValue;
  18. cout << "\nEnter Start Value : ";
  19. cin >> T1;
  20. cout << "\nEnter Second Value: ";
  21. cin >> T2;
  22.  
  23. double ratio = T2/T1;
  24.  
  25. while(1)
  26. {
  27. for(Uint Tn = 1;;++Tn)
  28. {
  29. if(maxValue > T1)
  30. {
  31. if(T1*pow((ratio), (double) Tn) > maxValue)
  32. {
  33. cout << "\n*--------------*\nFound it: n is " << Tn << "\n\n";
  34. break;
  35. }
  36. }
  37.  
  38. else
  39. {
  40. if(T1*pow((ratio), (double) Tn) < maxValue)
  41. {
  42. cout << "\n*--------------*\nFound it: n is " << Tn << "\n\n";
  43. break;
  44. }
  45. }
  46. }
  47.  
  48. cout << "\nDo new calc? ";
  49.  
  50. char result;
  51. cin >> result;
  52.  
  53. if(result == 'q')
  54. return 1;
  55. //otherwise
  56.  
  57. cout << "\nEnter Start Value : ";
  58. cin >> T1;
  59. cout << "\nEnter Second Value: ";
  60. cin >> T2;
  61. }
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment