幾個常見的「演算法」小程式

2021-09-08 07:57:12 字數 1268 閱讀 2853

1. 將字串「i am a good man」 輸出為:「man good a am i」

using

system;

namespace

class

program

console.readline();}}

} 2.  有一列數1,1,2,3,5,........求第30個數. (用遞迴)  這個**遍地都是,不解釋......

using

system;

namespace

class

program

public

static

intfoo(

inti)

else

if(i 

>0&&

i <=2)

else}}

} 3.有一組字串,要求輸入每種組合,例如:陣列輸出組合為:ab ac ,ba bc, ca cb

using

system;

namespace

class

program

;for

(inti =

0; i 

<

objstr.length; i++)

組組合為:

", i +1

);for

(intj =

0; j 

<

objstr.length; j++)

if(j 

==objstr.length -1

)}}console.readline();}}

} 4.列印5000以內的對稱數:如 11,111,121,1221(華為面試題)

using

system;

using

system.collections.generic;

using

system.linq;

using

system.text;

namespace

duishu

private

static

void

geta(

intmaxvalue)

else

if((index ==1

&&parta.equals(partb)) 

||(index 

>1&&

parta.equals(string.concat(partb.toarray().reverse()))))}}

}}}

幾個小程式

幾個c語言程式 一 如何 交換整形變數的內容?1.給定兩個整形變數的值,將兩個值的內容進行交換。includeint main 不允許建立臨時變數,交換兩個數的內容 includeint main 二 求max值 3.求10 個整數中最大值。include int main int max num ...

幾個shell小程式

說明 以下外殼指令碼,完成後全部拷貝至系統的公共可執行程式目錄,使得可以在任意目錄下執行 sudo cp hello calc mcp fileinfo guessnum bin helloshell bin中 你好 bin bash 宣告shell直譯器位置 word hello shell ec...

幾個VBA的小程式示例

1 判斷字串中是否包含另乙個字串 sub test1 dim str as string str 英屬維京群島持續發展控股 劉敦輝 ifinstr str,then msgbox 包含 else msgbox 不包含 endif endsub sub test2 dim str as string ...