From PPT....

個人覺得出的簡潔有力!

感覺可以出在研究所考題上面~


1.
extern void func1(void);
extern void func2(void);
extern void func3(void);
extern void func4(void);
extern void func5(void);


void main(int n)
{
  if n==1 execute func1;
  if n==2 execute func2;
  if n==3 execute func3;
  if n==4 execute func4;
  if n==5 execute func5;
}


保證 n 一定是上面五個數字之一
不能用if 和 switch case , 請用你認為最快的方法實作main

 


2.
extern void func1(void);
extern void func2(void);
extern void func3(void);
extern void func4(void);
extern void func5(void);


void main(int n)
{
  if n==33 execute func1;
  if n==67 execute func2;
  if n==324 execute func3;
  if n==231 execute func4;
  if n==687 execute func5;
}


保證 n 一定是上面五個數字之一
使用if, 請用你認為最快的方法實作main

 

想想看這兩題要怎麼解?!

要是沒有每天寫code,老實說我還真不知道要怎麼解!

chew it......

arrow
arrow
    全站熱搜

    owenhuangtw 發表在 痞客邦 留言(0) 人氣()