[問題] 我這樣很爛嗎?
把我應徵某公司考題的答案在這裡給這邊的大大鞭策
使用編譯程式 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
09/03 10:37, 1F
→
09/03 10:39, , 2F
09/03 10:39, 2F
推
09/03 11:02, , 3F
09/03 11:02, 3F
推
09/03 11:09, , 4F
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
09/03 12:06, 7F
→
09/03 12:06, , 8F
09/03 12:06, 8F
→
09/03 12:06, , 9F
09/03 12:06, 9F
→
09/03 12:14, , 10F
09/03 12:14, 10F
推
09/03 12:16, , 11F
09/03 12:16, 11F
→
09/03 12:18, , 12F
09/03 12:18, 12F
→
09/03 12:25, , 13F
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
09/03 14:32, 16F
推
09/03 14:43, , 17F
09/03 14:43, 17F
→
09/03 21:04, , 18F
09/03 21:04, 18F
→
09/03 21:43, , 19F
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
討論串 (同標題文章)
以下文章回應了本文:
問題
1
1
完整討論串 (本文為第 1 之 10 篇):
問題
4
6
問題
1
1
問題
2
6
問題
3
5
問題
2
9
問題
1
8
問題
7
12
問題
29
84
問題
9
29