#include <iostream>
using namespace std;
double fun(double x, int n) {
double val = 1.0;
while (n--)
{
val *= x;
}
return val;
}
int main() {
cout << "5 to 2 is" << fun(5, 2) << endl;
system("pause");
return 0;
using namespace std;
double fun(double x, int n) {
double val = 1.0;
while (n--)
{
val *= x;
}
return val;
}
int main() {
cout << "5 to 2 is" << fun(5, 2) << endl;
system("pause");
return 0;
}
循环只作用下一行,或者作用大括号里边的