作者andrewchiang (Andrew)
看板civil96
标题[心得] 计程Quiz答案
时间Tue Mar 18 20:51:32 2008
以下由本人随意豪洨完成的
答案并非为官方公布之解答
如果答案有错请麻烦推文指教
给大家当参考~
请记得开灯喔~
1.
(i) x - x*y + y - 5
(ii) y = 0.2*x*x + (b-a)*x /(b+a) + a/b
2.
First, you learn it because it's fun.
Second, you learn programming language so you can express your
ideas to accomplish task with computer.
3.
#include <fstream>
using namespace std;
int main()
{
ofstream fout("output.txt");
fout << "Einstein said \"make everything as simple as possible,";
fout << " but not simpler.\"" << endl;
fout << "Niels Bohr said \"prediction is very difficult, especially of ";
fout << "the future.\"" << endl;
fout.close();
return 0;
}
4.
#include <iostream>
using namespace std;
int main()
{
int input;
cin >> input ;
if (input%2==0)
cout <<"This is an even number."<< endl;
else
cout <<"This is an odd number."<< endl;
return 0;
}
5.
#include <iostream>
using namespace std;
int main()
{
long double i, n, x, sum;
const long double PI = 3.14159265358979323846243;
cout << "Please input n: ";
cin >> n;
cout << endl;
for (i=0; i<=n; i++)
{
x = (i - 0.5)/n;
sum = sum + 4/(1+x*x)/n;
}
cout <<"Pi estimate =" << sum <<endl;
cout <<"Percentage error = " << (sum - PI)*100 <<"%" << endl;
return 0;
}
--
http://www.wretch.cc/blog/andrewchiang ▃
▉▊◤ ◥ ▁▂▁ ├┤ ◤ ╮ ◥▎▏
▊◤ \ ⊙ ◢ ▁▂▁◆ ◆ ▇ ⊙ ︵ ◥▎
▊ ●◆──◆ 巛◆ ╰╯ ╣ ◆─◆) ▎
▊◣ / ⊙ ◥ ▇▆▅▄ ◆██████▁ ⊙ ︶ ◢▎
▉▊◣ ◢ ▇▆▅▆ ◣ ╯ ◢▎▏
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.112.241.112
1F:推 ivia:还可以这样讨论的喔= = 03/18 21:09
2F:推 c040723:交出去的时候会有很多一样的答案吧(茶) 03/18 21:16
3F:→ andrewchiang:这是模拟考题啊 03/18 21:18
4F:推 leethomas:让我想起高中电脑课的时候 大家都在家族PO答案XD 03/18 21:28
5F:推 shamangary:实在是太强啦 03/18 22:23
6F:推 tomroy:这不是应该低调吗? 03/18 22:46
7F:→ andrewchiang: D调 03/18 23:30
8F:→ joad:" Why you learn C++,Guys? " " Because I'm BORING!! " 03/18 23:32
※ 编辑: andrewchiang 来自: 140.112.241.112 (03/18 23:37)
9F:推 LonelyDream:我把你第五题输入9999999999run超久 03/18 23:42
10F:→ andrewchiang:是跑不动... 03/19 00:11
11F:推 aa1052v:低调不太成功 要每行都打喔 03/19 00:23
12F:→ andrewchiang:懒得打... 03/19 08:50