Advertisement
evage

Untitled

Nov 7th, 2021
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int readS() {
  5.     double s;
  6.     cout << "enter s\n";
  7.     do
  8.     {
  9.         cin >> s;
  10.         if (s <= 0)
  11.             cout << "wrong s\nEnter s again\n";
  12.     } while (s <= 0);
  13.     return s;
  14. }
  15. int readM() {
  16.     double M;
  17.     cout << "enter M\n";
  18.     do
  19.     {
  20.         cin >> M;
  21.         if (M <= 0)
  22.             cout << "wrong M\nEnter M again\n";
  23.     } while (M <= 0);
  24.     return M;
  25. }
  26.  
  27. int main() {
  28.     setlocale(LC_ALL, "ru");
  29.     double S, m, n, p;
  30.     /*for (; ; ) {
  31.         S = readS();
  32.         m = readM();
  33.  
  34.  
  35.  
  36.         cout << "Введите значение n. Количество лет:";
  37.         cin >> n; cout << '\n';
  38.         if (n <= 0) {
  39.             cout << "Введите другое значения n (n > 0)" << endl;
  40.         }
  41.         if (S > 0 && m > 0 && n > 0) {
  42.             break;
  43.         }
  44.     }*/
  45.     S = readS();
  46.     ...
  47.     //r = p / 100;
  48.     //ясно, что общая сумма выплат - это S * r , где r = p/100 => s * p /100 , а еще это m * n * 12, тогда
  49.     //нужно решить уравнение p= (12 * m * n * 100)/S;
  50.  
  51.     p = (12 * m * n * 100) / S;
  52.     cout << p;
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement