Facebook
From Flying Kitten, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 257
  1. #include <string>
  2. #include <iostream>
  3. #include "sstream"
  4.  
  5. using namespace std;
  6. int potegi(int wyk,int podst);
  7.  
  8. int main()
  9. {
  10.     int t;
  11.     int a;
  12.     int b;
  13.     cin>>t;
  14.     while(t--)
  15.     {
  16.         cin>>b;
  17.         cin>>a;
  18.         ostringstream ss;
  19.         ss << potegi(a,b);
  20.         string jednosci = ss.str();
  21.         cout<<jednosci[jednosci.length()-1]<<endl;
  22.     }
  23.     return 0;
  24. }
  25. int potegi(int wyk,int podst)
  26. {
  27.     if(wyk==1) return podst;
  28.     else return podst* potegi(wyk-1,podst);
  29. }
  30.