回分類題庫
d225: 101OOP Lab Exercise: Vector Practice
出處:

Difficulity : N/A
Accepted : 48 Times | Submit :121 Times | Clicks : 1174
Accepted : 46 Users | Submit : 47 Users | Accepted rate : 98%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2012-10-19 21:58

Content :

This Vector Practice records a set of name.

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

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

 

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

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

Input :

There are several sets of test data.

For each set of data:

 The first line is an integer N indicates the number of the Student. 

 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 waring message ”Insert Wrong Place!!”

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

If not, output a waring message ”Delete Wrong Place!!”

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

If not, output a waring message ”Delete Wrong Number!!”

4.       If the instruction is Replace and the original name doesn’t exist, output a waring message ”Can't find!!”

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

Sample Input :

2
Orange Iris
Insert 3 2 TPA EZ
Insert 0 2 TPA EZ
Delete 4 1
Delete 4 2
Delete 3 2
Delete 3 1
Quit
6
Liballz Toyz Mistake Stanley Colalin Bebe
Insert 4 2 Orange Iris
Insert 7 2 Vladimir Ezreal 
Insert 1 1 TeacherLi
Delete 11 1
Delete 10 1
Replace Bebe Lulu
Replace Colalin Caitlyn
Delete 0 11
Delete 5 5
Delete 1 1
Insert 4 4 Colalin Bebe GodJJ Zonda
Quit

Sample Output :

Orange Iris
------------------------------------------------------------------------------------------
Insert Wrong Place!!
------------------------------------------------------------------------------------------
TPA EZ Orange Iris
------------------------------------------------------------------------------------------
Delete Wrong Place!!
------------------------------------------------------------------------------------------
Delete Wrong Place!!
------------------------------------------------------------------------------------------
Delete Wrong Number!!
------------------------------------------------------------------------------------------
TPA EZ Orange
------------------------------------------------------------------------------------------
Liballz Toyz Mistake Stanley Colalin Bebe
------------------------------------------------------------------------------------------
Liballz Toyz Mistake Stanley Orange Iris Colalin Bebe
------------------------------------------------------------------------------------------
Liballz Toyz Mistake Stanley Orange Iris Colalin Vladimir Ezreal Bebe
------------------------------------------------------------------------------------------
Liballz TeacherLi Toyz Mistake Stanley Orange Iris Colalin Vladimir Ezreal Bebe
------------------------------------------------------------------------------------------
Delete Wrong Place!!
------------------------------------------------------------------------------------------
Liballz TeacherLi Toyz Mistake Stanley Orange Iris Colalin Vladimir Ezreal
------------------------------------------------------------------------------------------
Can't find!!
------------------------------------------------------------------------------------------
Liballz TeacherLi Toyz Mistake Stanley Orange Iris Caitlyn Vladimir Ezreal
------------------------------------------------------------------------------------------
Delete Wrong Number!!
------------------------------------------------------------------------------------------
Liballz TeacherLi Toyz Mistake Stanley
------------------------------------------------------------------------------------------
Liballz Toyz Mistake Stanley
------------------------------------------------------------------------------------------
Liballz Toyz Mistake Stanley Colalin Bebe GodJJ Zonda
------------------------------------------------------------------------------------------

Hint :


  

Author :

(管理員:oop10101)

  Solve it!   Status Forum (0)

C++
C
JAVA
43992. oop100703031 (6 ms , 452KB)
41941. oop98703053 (6 ms , 422KB)
41878. oop100703022 (6 ms , 462KB)
41845. oop100703016 (6 ms , 424KB)
41843. oop100703037 (6 ms , 424KB)
沒有解題記錄 57650. nwgs524513cja (102 ms , 188KB)

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