Witam mam problem z tym kodem, code blocks wypisuje mi wynik 5^2 jako 24 (4 zawsze zastępuje 5). Problem występuje na wsyztskich potęgach 5. Ponad to wyskakują w sporych podstawach i ich wykładnikach wylicza mi wynik -8. Prosze o pomoc i pozdrawiam.
#include <iostream>
#include <cstdlib>
#include <math.h>
using namespace std;
int test,b,a,roz[31],odp[31];
double g(long int a,long int b)
{
if(b==0)
{
return 1;
}
else if (b==1)
{
return a;
}
else
{
long int c;
c=pow(a,b);
return c;
}
}
int main()
{
cin>>test;
system("cls");
for(int d=1; d<=test; d++)
{
cin>>a;
cin>>b;
system("cls");
roz[d]=g(a,b);
odp[d]=roz[d]%10;
cout<<odp[d]<<endl;
}
return 0;
}