b0b3kpl

Potegi

Sep 8th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <iostream>
  4. #include <math.h>
  5. #include <string>
  6. #include <cstdlib>
  7.  
  8. using namespace std;
  9.  
  10. void countandwrite(double *arr, int how)
  11. {
  12.     string str, strl;
  13.     double last;
  14.  
  15.     for (int i = 0; i < how; i++)
  16.     {
  17.         str = to_string(int (pow(arr[0, i], arr[1, i])));
  18.  
  19.         cout << "Power:" << str << endl;
  20.  
  21.         strl = str.back();
  22.         last = stod(strl);
  23.  
  24.         cout << "Last character:" << last << endl;
  25.     }
  26. }
  27.  
  28. int main()
  29. {
  30.     int how;
  31.  
  32.     cout << "Number of powers:";
  33.    
  34.     cin >> how;
  35.  
  36.     double *arr;
  37.     arr = new double[2, how];
  38.  
  39.     for (int j = 0; j < how; j++)
  40.     {
  41.         cout << "Number:";
  42.         cin >> arr[0, j] >> arr[1, j];
  43.         cout << endl;
  44.     }
  45.  
  46.     countandwrite(arr, how);
  47.  
  48.     delete[]arr;
  49.  
  50.     system("pause");
  51.  
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment