0
What is the problem?
#include <iostream> using namespace std; int pow(int a ,int b) { int p=1,i; for(i=1;i<=b;i++) p=p*a; return p; } int f(int a,int b) { return pow(a,b)/pow(a+3*b,2); } int main() { int a,b; cin>>a>>b; cout<<f(a,b); return 0; }
4 Réponses
+ 1
//so it should work
#include <iostream>
using namespace std;
int pow(int a ,int b)
{
int p=1,i;
for(i=1;i<=b;i++)
p=p*a;
return p;
}
double f(int a,int b)
{
return double(pow(a,b))/pow(a+3*b,2);
}
int main() {
int a,b;
cin>>a>>b;
cout<<f(a,b);
return 0;
}
0
There is no error ,answer is right
enter inputs like this way
5
6
0
add this to debug it and see the last result is 0.
for(i=1;i<=b;i++){
p=p*a;
cout << p <<endl;
}
what did you expect?