回分類題庫
d237: 102OOP Lab Exercise: Vector Practice
出處:

Difficulity : N/A
Accepted : 46 Times | Submit :82 Times | Clicks : 869
Accepted : 44 Users | Submit : 45 Users | Accepted rate : 98%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2013-10-16 13:01

Content :

This Vector Practice records a set of names.

Then we can Insert new names, Delete names, and Replace a name.

Your task is to write a file:  Main.cc in C++.

 

Main.cc is an implementation of handling input, output ...etc.

 

Adding some functions is always a good idea.  (e.g., Print function, … etc.)

Input :

There are several sets of test data.

For each set of data:

 The first line is an integer N indicating the number of Students.

 The second line contains N names separated by space.

 

 The instruction is: Insert, Delete, Replace, Quit

 Then, Read instructions to print or modify the data.

 There are four instructions as following:

     Insert [place] [number of names] [names(separated by spacce)]

     Delete [place] [number of names]

     Replace [original name] [modified name]

     Quit

 

When inputting “Quit”, start the next set of test data.

Output :

Please refer to sample output.

 

    Note that you have to check

1.      The Insert place can only be between [0] and [the place of the last name+1]

If not, output a warning message “Insert Wrong Place!!”

2.      The Insert command should prevent duplicated input.

If the name already exists, output a warning message “[Name] already exists!!”

3.      The Delete place can only be between [the place of the first name] and [the place of the last name]

If not, output a warning message “Delete Wrong Place!!”

4.      The Delete number must not exceed the number of names

If not, output a warning message “Delete Wrong Number!!”

5.      If the instruction is Replace and the original name doesn’t exist, output a warning message “Can’t find!!”

 

 (Print ‘------------------------------------------------------------------------------------------’ after outputting the result of an instruction)

Sample Input :

5
Chloe Rachel Sara Cinzia Sonia
Insert 3 2 Eros Jupiter
Insert 0 2 Eros Allen
Insert 9 2 Eros Jupiter
Delete 4 1
Delete 4 2
Delete 7 5
Delete 4 2
Quit
6
Albert Shines Rene Stanley Johannes Galileo
Insert 4 1 Rachel
Insert 7 2 Leonardo Ezio
Insert 1 1 Marie
Delete 11 1
Delete 3 2
Replace Torricelli Lala
Replace Johannes Caitlyn
Delete 0 11
Delete 5 5
Delete 1 1
Insert 4 4 Johannes Galileo Stephen Thomas
Quit

Sample Output :

Chloe Rachel Sara Cinzia Sonia
------------------------------------------------------------------------------------------
Chloe Rachel Sara Eros Jupiter Cinzia Sonia
------------------------------------------------------------------------------------------
Eros already exists!!
------------------------------------------------------------------------------------------
Allen Chloe Rachel Sara Eros Jupiter Cinzia Sonia
------------------------------------------------------------------------------------------
Insert Wrong Place!!
------------------------------------------------------------------------------------------
Allen Chloe Rachel Sara Jupiter Cinzia Sonia
------------------------------------------------------------------------------------------
Allen Chloe Rachel Sara Sonia
------------------------------------------------------------------------------------------
Delete Wrong Place!!
------------------------------------------------------------------------------------------
Delete Wrong Number!!
------------------------------------------------------------------------------------------
Albert Shines Rene Stanley Johannes Galileo
------------------------------------------------------------------------------------------
Albert Shines Rene Stanley Rachel Johannes Galileo
------------------------------------------------------------------------------------------
Albert Shines Rene Stanley Rachel Johannes Galileo Leonardo Ezio
------------------------------------------------------------------------------------------
Albert Marie Shines Rene Stanley Rachel Johannes Galileo Leonardo Ezio
------------------------------------------------------------------------------------------
Delete Wrong Place!!
------------------------------------------------------------------------------------------
Albert Marie Shines Rachel Johannes Galileo Leonardo Ezio
------------------------------------------------------------------------------------------
Can't find!!
------------------------------------------------------------------------------------------
Albert Marie Shines Rachel Caitlyn Galileo Leonardo Ezio
------------------------------------------------------------------------------------------
Delete Wrong Number!!
------------------------------------------------------------------------------------------
Delete Wrong Number!!
------------------------------------------------------------------------------------------
Albert Shines Rachel Caitlyn Galileo Leonardo Ezio
------------------------------------------------------------------------------------------
Galileo already exists!!
------------------------------------------------------------------------------------------
Albert Shines Rachel Caitlyn Johannes Stephen Thomas Galileo Leonardo Ezio
------------------------------------------------------------------------------------------

Hint :


  

Author :

(管理員:oopTA)

  Solve it!   Status Forum (0)

C++
C
JAVA
48180. oop101703043 (4 ms , 422KB)
48278. oop101703025 (6 ms , 426KB)
48268. oop101703030 (6 ms , 430KB)
48267. stu9811 (6 ms , 424KB)
48261. oop101703032 (6 ms , 426KB)
沒有解題記錄 57685. nwgs524513cja (92 ms , 204KB)

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡