lucacodorean

Untitled

Feb 5th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. vector<int>x;
  8. vector<int>z;
  9.  
  10. vector<int>inmultire(vector<int> x, int y)
  11. {
  12.     vector<int>aux;
  13.     int t=0;
  14.     for(int i=0; i<x.size(); i++)
  15.     {
  16.         t=t+x[i]*y;
  17.         aux.push_back(t%10);
  18.         t/=10;
  19.     }
  20.  
  21.     while(t!=0)
  22.     {
  23.         aux.push_back(t%10);
  24.         t/=10;
  25.     }
  26.  
  27.     reverse(aux.begin(), aux.end());
  28.     return aux;
  29. }
  30.  
  31. vector<int>power(int e, int b)
  32. {
  33.     int aux=e;
  34.     vector<int> cv;
  35.     if(b==0)
  36.     {
  37.         cout<<"1";
  38.     }
  39.  
  40.     while(aux)
  41.     {
  42.         z.push_back(aux%10);
  43.         aux/=10;
  44.     }
  45.     for(int i=1; i<=b; i++)
  46.     {
  47.         cv = inmultire(z,e);
  48.     }
  49.  
  50.     reverse(z.begin(), z.end());
  51.  
  52.     for(const auto &it : z)
  53.     {
  54.         cout<<it;
  55.     }
  56. }
  57.  
  58. int main()
  59. {
  60.     int f,n;
  61.     cin>>f>>n;
  62.  
  63.     power(f,n);
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment