[問題] 我這樣很爛嗎?

看板C_and_CPP作者 (活著是件難過的事)時間13年前 (2012/09/03 02:25), 編輯推噓9(9020)
留言29則, 18人參與, 最新討論串1/10 (看更多)
把我應徵某公司考題的答案在這裡給這邊的大大鞭策 使用編譯程式 codeblock C++ 1. There are four digits on the face of a 12‐hr digital clock. How many times in oneday (24 hours) can you see three or more of the same number in a row (e.g.,01:11, 02:22, etc) on the clock face? In addition, please use any programming language, pseudo‐code, or flow‐chart to write an algorithm to compute the answer. 2. Please design a rough architecture of an online paper‐scissor‐stone game. Be as imaginative as you can in terms of functionality and architecture. You may use UML or simple block diagrams for your design. 3. Please use any programming language, pseudo‐code, or flow‐chart to implement an algorithm for the following equation: Yn=Xn^2-Xn-1*Xn+1 1. answer: #include <iostream> #include <stdlib.h> using namespace std; int main() { int x,a, b, c, d, h, m; int t=0; for (x=0; x<720; x++) { h=x/60; m=x%60; a=h/10; b=h%10; c=m/10; d=m%10; if (a==b && a==c && a==d ) { t++; cout<<a<<b<<c<<d<<endl; } else if (a==b && a==c && a!=d) { t++; cout<<a<<b<<c<<d<<endl; } else if (a!=b && a==c && a==d) { t++; cout<<a<<b<<c<<d<<endl; } else if(a==b && a!=c && a==d) { t++; cout<<a<<b<<c<<d<<endl; } else if(c==b && a!=b && c==d) { t++; cout<<a<<b<<c<<d<<endl; } } cout<<t*2<<endl; cout<<x<<endl; system("pause"); return 0; } 2.answer: #include <iostream> #include <stdlib.h> #include <stdio.h> #include <time.h> using namespace std; void randomize() { time_t t; srand((unsigned) time(&t)); } int main(void) { randomize(); int x,y,z,r; cout << "請輸入你要出的拳種 0.剪刀,1.石頭,2.布" << endl; cin>>x; r=rand(); y=r%3; z=x-y; if (x==0) { cout <<"你出的是剪刀"<<endl; } } else if (x==1) { cout <<"你出的是石頭"<<endl; } } else if (x==2) { cout <<"你出的是布"<<endl; } } else { cout <<"請輸入0~2的整數"<<endl; } if (y==0) { cout <<"電腦出的是剪刀"<<endl; } } else if (y==1) { cout <<"電腦出的是石頭"<<endl; } } else if (y==2) { cout <<"電腦出的是布"<<endl; } if (z==0) { cout<<"平手"<<endl; } else if(z==-2||z==1) { cout<<"你贏了"<<endl; } else if(z==2||z==-1) { cout<<"你輸了"<<endl; } cout<<r<<endl; cout<<y<<endl; return 0; } 3.answer: #include <iostream> #include <stdlib.h> #include <stdio.h> using namespace std; int main() { int i,max,n; cout << "X(i)=1,0<=1<=N" << endl; cout << "Y(n)=X(n)*X(n)-X(n-1)*X(n+1)" << endl; cout << "0<n<N" << endl; cout << "N=?" << endl; cin>> max; n=max-1; int x[max],y[max]; for(i=0;i<max+1;i++) { x[i]=1; } for (i=0;i<n;i++) { y[i]=(x[i+1]*x[i+1])-(x[i+2]*x[i]); cout<<"y("<<i<<")="<<y[i]<<endl; } return 0; } 這樣很沒有邏輯 架構嗎? 感覺很悶... 是不是接下來的programmer都會被打槍Q_Q -- ████ * http://ppt.cc/M9C4 臉書 http://0rz.tw/tkNbW 噗浪 ███◣ █ █ . ☆█ ◥█ ,告訴你,我沒有朋友喔 ████ ███ ███◣ ███◣ █ █ █ █ █ 你要當我的朋友嗎? █── █ █ █ ◢█ * §hilulu01 ███◤*█ ███◤ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.122.103.67

09/03 10:37, , 1F
abcdxyz......
09/03 10:37, 1F

09/03 10:39, , 2F
if else那邊的縮排也很難看....orz
09/03 10:39, 2F

09/03 11:02, , 3F
這真是驚人的變數名稱..
09/03 11:02, 3F

09/03 11:09, , 4F
包含bug與誤用VLA,大約是資訊系大二學生寫出來的code
09/03 11:09, 4F

09/03 11:35, , 5F
你應該是自修學的吧
09/03 11:35, 5F

09/03 11:53, , 6F
學校裡面大部分都是這樣 沒空白就很好了
09/03 11:53, 6F

09/03 12:06, , 7F
#include <iostream>
09/03 12:06, 7F

09/03 12:06, , 8F
#include <stdlib.h>
09/03 12:06, 8F

09/03 12:06, , 9F
這兩個一起引用是新手證明
09/03 12:06, 9F

09/03 12:14, , 10F
有 spec 說 iostream 一定會 include stdlib.h 嗎?
09/03 12:14, 10F

09/03 12:16, , 11F
#include <cstdlib>
09/03 12:16, 11F

09/03 12:18, , 12F
我誤會 damody 的意思了 @@
09/03 12:18, 12F

09/03 12:25, , 13F
我也是剛畢業阿Q_Q 我是機電系的 除了寫8051外沒寫過了
09/03 12:25, 13F
※ 編輯: skizzy 來自: 140.122.103.67 (09/03 12:30) ※ 編輯: skizzy 來自: 140.122.103.67 (09/03 12:32)

09/03 12:42, , 14F
變數命名方式是大忌,我如果是考官看到那行就不會繼續看
09/03 12:42, 14F

09/03 12:43, , 15F
其他不論,命名跟排版一定要改進
09/03 12:43, 15F

09/03 14:32, , 16F
推x y x r命名法
09/03 14:32, 16F

09/03 14:43, , 17F
我在做測試的時候也都有xyz,dont mind
09/03 14:43, 17F

09/03 21:04, , 18F
第2題最難,題目是online的,考架構。
09/03 21:04, 18F

09/03 21:43, , 19F
x y z 啥鬼...
09/03 21:43, 19F

09/03 23:47, , 20F
資訊系大二也太誇張 哪個資訊系會教人這樣寫的.....
09/03 23:47, 20F

09/03 23:56, , 21F
畢業不會寫程式的都有了
09/03 23:56, 21F

09/04 00:53, , 22F
那是少數吧 我以為這是在講平均程度
09/04 00:53, 22F

09/04 00:54, , 23F
多數
09/04 00:54, 23F

09/04 00:54, , 24F
研究所考試不會考程式,所以...
09/04 00:54, 24F

09/04 04:46, , 25F
平均程度很低啊,當然名校的、平均也許比較高吧...
09/04 04:46, 25F

09/04 08:59, , 26F
母校是考進去以後要考程式會考,沒過要修課
09/04 08:59, 26F

09/04 10:30, , 27F
很多人不喜歡寫程式,但是很奇妙她們大部分選擇資訊工作
09/04 10:30, 27F

09/04 21:14, , 28F
第三題,你可以看像這樣的資料來幫助你想想怎麼寫程式.
09/04 21:14, 28F

09/09 08:22, , 29F
很強了!我資工畢業還不會寫程式呢!!!!
09/09 08:22, 29F
文章代碼(AID): #1GH1KXuh (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1GH1KXuh (C_and_CPP)