#include <iostream>
//#include <math.h>
//#include <iomanip>
//#include <stdio.h>
using namespace std;
double f1(double x)
{
return(2*x);
}
double f2(double x)
{
return(x*x);
}
double compute(double f(double x), double i)
{
double answer;
answer = f(i);
return (answer);
}
int main()
{
double input, ans;
int function;
double (*gset[])(double)={f1,f2};
cout << "Input Please: ";
cin >> input;
cout << "Function Please: ";
cin >> function;
ans = compute(gset[function-1], input);
cout << ans;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgovLyNpbmNsdWRlIDxtYXRoLmg+Ci8vI2luY2x1ZGUgPGlvbWFuaXA+Ci8vI2luY2x1ZGUgPHN0ZGlvLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAgIApkb3VibGUgZjEoZG91YmxlIHgpCnsKICAgIHJldHVybigyKngpOwp9Cgpkb3VibGUgZjIoZG91YmxlIHgpCnsKICAgIHJldHVybih4KngpOwp9Cgpkb3VibGUgY29tcHV0ZShkb3VibGUgZihkb3VibGUgeCksIGRvdWJsZSBpKQp7CiAgICAgICBkb3VibGUgYW5zd2VyOwogICAgICAgYW5zd2VyID0gZihpKTsKICAgICAgIHJldHVybiAoYW5zd2VyKTsgICAgICAgCn0KCmludCBtYWluKCkKewogICAgZG91YmxlIGlucHV0LCBhbnM7CiAgICBpbnQgZnVuY3Rpb247CiAgICAKICAgIGRvdWJsZSAoKmdzZXRbXSkoZG91YmxlKT17ZjEsZjJ9OwogICAgCiAgICBjb3V0IDw8ICJJbnB1dCBQbGVhc2U6ICI7CiAgICBjaW4gPj4gaW5wdXQ7CiAgICBjb3V0IDw8ICJGdW5jdGlvbiBQbGVhc2U6ICI7CiAgICBjaW4gPj4gZnVuY3Rpb247CiAgICAKICAgIGFucyA9IGNvbXB1dGUoZ3NldFtmdW5jdGlvbi0xXSwgaW5wdXQpOwogICAgY291dCA8PCBhbnM7Cn0=