作者sb0917 (QQ)
看板NTUBIME101HW
标题[C++] 期中考古-方程式运算
时间Sat Nov 15 19:56:10 2008
#include <iostream>
using namespace std;
int function(int );
int main()
{
int i;
for(i=1;i<21;i++)
cout << "y(" << i << ") = " << function(i) << endl;
system("pause");
return 0;
}
int function(int x)
{
if(x < 4)
return x*x - 1;
else if(x >= 4 && x <= 10)
return x*x*x - 15*x - 4;
else
return 8*x*x + 46;
}
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 125.232.106.25