Advertisement
Guest User

2.1.2

a guest
Oct 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. #include "math.h"
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     double a;
  9.     int n;
  10.     int k;
  11.     cout << "Enter number="; cin >> a;
  12.     cout << "Enter n="; cin >> n;
  13.     cout << "Enter k="; cin >> k;
  14.     for (int i = 0; i < n; i++)
  15.     {
  16.         a *= 10;
  17.     }
  18.     int b;
  19.     b = a;
  20.     a -= b;
  21.     int S = 0;
  22.     for (int i = 0; i < k; i++)
  23.     {
  24.         int c;
  25.         c = a * 10;
  26.         S += c;
  27.         a *= 10;
  28.         a -= c;
  29.     }
  30.     cout << endl << "Answer:" << S << endl;
  31.     system("pause");
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement