Advertisement
Kolyach

3

Sep 17th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <cmath>
  4. #include <fstream>
  5. #include <string>
  6.  
  7. using namespace std;
  8.  
  9. void hw3_1();
  10. void hw3_2();
  11. void hw3_3();
  12. void hw3_4();
  13. void hw3_5();
  14.  
  15. int main()
  16. {
  17.     setlocale(LC_ALL, "russian");
  18.     hw3_1();
  19.     /*hw3_2();
  20.     hw3_3();*/
  21.     /*hw3_4();
  22.     hw3_5();*/
  23.     return 0;
  24. }
  25.  
  26. void hw3_1() {
  27.     float p, m, S, r;
  28.     int n;
  29.     cout << "Введите p, S, n: ";
  30.     cin >> p >> S >> n;
  31.     if (p > 0 && S > 0 && n > 0) {
  32.         r = p / 100;
  33.         m = (S*r*pow(1 + r, n)) / (12 * (pow(1 + r, n) - 1));
  34.         cout << "m=" << m << endl;
  35.     }
  36.     else cout << "p, S, n должны быть больше 0!" << endl;
  37. }
  38.  
  39. void hw3_2() {
  40.     float p, m, S, r;
  41.     int n;
  42.     cout << "Введите S, n, m: ";
  43.     cin >> S >> n >> m;
  44. }
  45.  
  46. void hw3_3() {
  47.     char ch;
  48.     ifstream fin;
  49.     fin.open("D:\\hw3\\kpop.txt");
  50.     while (fin.get(ch)) {
  51.         cout << ch;
  52.     }
  53.     fin.close();
  54. }
  55.  
  56. void hw3_4() {
  57.     char ch;
  58.     ifstream fin;
  59.     fin.open("D:\\hw3\\kpop.txt");
  60.     while (fin.get(ch)) {
  61.         if ((ch >= '0' && ch <= '9') || ch==' ' || ch=='\n') {
  62.             cout << ch;
  63.         }
  64.     }
  65.     fin.close();
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement