2007年4月19日 星期四

Manage Business Card

二、Write a program that allows user to manage his business card collection.

C:\>cardfile cardfile.dat

Your program should be able to support the following function by a single linked list structure:
1. Add or delete a card to or from the data file.
2. Find a card based on name search.
3. Edit an existing card (change the phone number or company)
4. List the contents of the file (in alphabetical order)
5. Quit (save changes)

The business card (card structure) should include the following information:
Name (30 characters)
Phone (15 characters)
Company (40 characters)

<Example of command line>:Add name、phone number and company line by line:
Chris Lee
5252000
Dept. of EE、NSYSU
<Example of command line>: Find Chris Lee
<Example of command line>: Edit Chris Lee
<Example of command line>: List Chris Lee
<Example of command line>: List All

Your program should give user the necessary messages、such as usage of your program and some necessary error messages.

<hint>


The format of the data file is one line per card record with a tab as a field separator. The data is read in a line at a time by the fgets() function、the newline character is removed、and the data fields
extracted by successive calls to the strtok()、which copies tokens from a data stream.


困難度:*
時間複雜度:O(n)
程式語言:C++
預估時間:3 小時

解題原理:
1. 透過終端機介面判斷欲選擇的功能
2. 使用單向鏈結串列進行資料的新增、修改、刪除、尋找和排序
3. 根據使用者選擇的指令在終端機介面上顯示
4. 完成

程式下載


原碼下載

參考來源:中山大學八十九學年度電腦程式設計競賽 試題 二

沒有留言: