CSE102 – C程式設計實習 雙周測驗 (Solution)

$ 30.00
Category:

Description

2023.12.07
1. (50%) Please let the user to enter a positive number in decimal base, your task is to write them in the Fibonaccimal base.
17= 1 0 0 1 0 1
13+3+1= 13 8 5 3 2 1

25= 1 0 0 0 1 0 1
21+3+1= 21 13 8 5 3 2 1

50= 1 0 1 0 0 1 0 1
34+13+3+1= 34 21 13 8 5 3 2 1

Noted:

a. In order to ensure that all positive integers have only one set of representations, any two selected terms cannot be adjacent in the sequence.
b. The leftmost digit must be 1 and cannot be 0.
c. Please use continuous input.
d. The value entered cannot be greater than 100,000,000.
e. You should output with the format DEC_BASE = FIB_BASE (fib). DEC_BASE is the original number in decimal base and FIB_BASE is its representation in Fibonaccimal base.
g. Terminate the program when the input is 0.

Sample Input:

1
2
3
4
5
6
7
8
9
10
17
25
50
1000
10000000

Sample Output:
1 = 1 (fib)
2 = 10 (fib)
3 = 100 (fib)
4 = 101 (fib)
5 = 1000 (fib)
6 = 1001 (fib)
7 = 1010 (fib)
8 = 10000 (fib)
9 = 10001 (fib)
10 = 10010 (fib)
17 = 100101 (fib)
25 = 1000101 (fib)
50 = 10100100 (fib)
1000 = 100000000100000 (fib)
10000000 = 1000001010010010100001000000100100 (fib)

2. (50%) Please reading a string from standard input and printing the text within double quotes. The double quotes are represented as “. The output should display the text within the double quotes, and each line should end with a newline character.
Noted:
a. Please use continuous input.
b. Each line would not exceed 2048 characters.
c. The print format must be like the picture below.
d. Terminate the program when the input is 0.
e. The task necessitates using pointers.

Input

Output

Sample Input: book is “red and black” apple is “good” and “bad” good “Hoz” “apple is good”
Sample Output: red and black good bad Hoz apple is good

Reviews

There are no reviews yet.

Be the first to review “CSE102 – C程式設計實習 雙周測驗 (Solution)”

Your email address will not be published. Required fields are marked *