作者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
推 ivia:還可以這樣討論的喔= = 03/18 21:09
推 c040723:交出去的時候會有很多一樣的答案吧(茶) 03/18 21:16
→ andrewchiang:這是模擬考題啊 03/18 21:18
推 leethomas:讓我想起高中電腦課的時候 大家都在家族PO答案XD 03/18 21:28
推 shamangary:實在是太強啦 03/18 22:23
推 tomroy:這不是應該低調嗎? 03/18 22:46
→ andrewchiang: D調 03/18 23:30
→ joad:" Why you learn C++,Guys? " " Because I'm BORING!! " 03/18 23:32
※ 編輯: andrewchiang 來自: 140.112.241.112 (03/18 23:37)
推 LonelyDream:我把你第五題輸入9999999999run超久 03/18 23:42
→ andrewchiang:是跑不動... 03/19 00:11
推 aa1052v:低調不太成功 要每行都打喔 03/19 00:23
→ andrewchiang:懶得打... 03/19 08:50