Description
Objective :
Learn how to use file input and output, strings, struct, and functions.
13.1
Write a program to record and update book information in a library. Each book’s information will include the title, author’s name, publication year, and book ID. You need to implement the following functions: Reading Book Data: Read book information from “books.txt”. Assume each line represents a book, formatted as: Title, Author, Publication Year, Book ID.
Updating Book Information: Allow the user to update the book’s information, and write the updated information back to “books.txt”. Displaying Book Information: Print all the book’s information on the screen.
Hints:
The struct is used to store information for each book, which includes title, author, year, and id.
Outputs:
13.2
Write a program to generate 1000 distinct numbers, where each value is between 1000 and 10000 and store them in ‘test.txt,’ then performs a bubble sort on the sequence of numbers in ‘test.txt’. After sorting the numbers in ascending order, write the results into ‘sorted.txt’ and output them to the console. Then, load the sorted sequence to perform a Binary Search.
Hints:
Both the bubble sort and Binary Search should be implemented as functions.
The names of the functions are generate( ), bubbleSortRecursive( ), swap( ), and binarySearchRecursive( ) respectively.
The bubble sort and Binary Search should be written recursively. In the bubble sort, the swap function must be implemented using pointers.
Error handling is required in case a number is not found.
Output :
Please note:: users of visual studio add the following code to your program’s beginning
繳交格式及規定 : 程式重點地方請加註解,給分也會酌量參考註解。
請繳交 .c 檔即可。
c 檔的檔名一律統一,以學號為檔名壓縮成一個以學號為名的壓縮檔
上傳,
上傳請一律繳交壓縮檔。
Example: 若學號為 B123456789, 則.c/.cpp 檔名為 B123456789.c , 而壓縮檔名為 B123456789.rar。
繳交期限 2023.12.21 (四) 09:00 分之前,逾期一律不收,
無輸入輸出及逾期者一律以 0 分計算。
作業請上傳中山網路大學 網大上傳方式:
1. 點選要繳交的作業,選擇「進行作業」。
2. 依照流程上傳檔案。
Reviews
There are no reviews yet.