• 沒有找到結果。

輸入:任意整數 N ( 0<= N <= 2147483647 )

N/A
N/A
Protected

Academic year: 2022

Share "輸入:任意整數 N ( 0<= N <= 2147483647 )"

Copied!
7
0
0

加載中.... (立即查看全文)

全文

(1)

C/C++ 自我挑戰題

第一部分:共 6 題

(2)

輸入:任意整數 N ( 0<= N <= 2147483647 )

輸出:其二進位的值。

範例:

輸入: 5

輸出: 101

輸入: 63

輸出: 111111

(1) 十進位轉二進位

(3)

(2) 插入排序法( Insertion Sor t )

讓使用者輸入 6 個資料的一維陣列,使用插入排序法將之 由小排到大:

規定左方為已排好的數列(藍色),將右方未排數列(紫色)的第 一個數字一直向左交換,直到順序正確為止。

36 8 15 12 40 3

8 36 15 12 40 3

8 15 36 12 40 3

8 12 15 36 40 3

j = 1 j = 2 j = 3 j = 4

j

(4)

(3) 找質數

讓使用者輸入一個正整數 n ,請印出 1~n 這個範圍

間的質數有哪些( n<100000 )

(5)

使用二維陣列,讓使用者任意輸入 5 個英文單字(每個單 字不超過 10 個字元)後,再將之使用字典順序由小排到 大輸出。

提示:二維陣列 + strcmp() + strcpy() + 氣泡 ( 或插入 ) 排 序法。

(4) 字典排序

zebra cat ball dog apple

apple ball cat dog zebra

輸入: 輸出:

(6)

試建立一個大小為 49 的陣列,並且在這個陣列中隨機填 入 1~49 的整數,你必須想出一個演算法讓這個過程最快。

(目前最快的方法其時間複雜度為 O(N) )

(5) 亂數 49

(7)

請試使用學過的函式與指標的技巧,實作出 strlen (), strcpy() 與 strcmp() 這三個函式的功能。

(6) 字串函式實作

參考文獻

相關文件

[r]

An n×n square is called an m–binary latin square if each row and column of it filled with exactly m “1”s and (n–m) “0”s. We are going to study the following question: Find

[r]

A subgroup N which is open in the norm topology by Theorem 3.1.3 is a group of norms N L/K L ∗ of a finite abelian extension L/K.. Then N is open in the norm topology if and only if

We compare the results of analytical and numerical studies of lattice 2D quantum gravity, where the internal quantum metric is described by random (dynamical)

• 我們通常用 nD/mD 來表示一個狀態 O(N^n) ,轉移 O(N^m) 的 dp 演算法. • 在做每題

Without using ruler, tearing/cutting of paper or drawing any line, use the square paper provided (Appendix A) to fold the figure with the same conditions as figure 8b, but the area

n Logical channel number and media information (RTP payload type). n Far endpoint responds with Open Logical