回分類題庫
d222: 101OOP Lab Exercise: StringFilter
出處:

Difficulity : N/A
Accepted : 54 Times | Submit :87 Times | Clicks : 1272
Accepted : 53 Users | Submit : 53 Users | Accepted rate : 100%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2012-10-01 17:34

Content :

A String Filter can remove specific strings of a string. Your task is to write a function: StringFilter in C++. Luckily, we provide a code segment which handles the input from user, therefore, you can focus on writing the function.
In this code segment, the function "StringFilter" takes two strings: "origin" and "filter" as arguments. It returns the filtered string of the origin.

For example, if input is
"Hello World"
"World"
, then the output is
"Hello "
Note that there is no newline generated by this function.?
Remember your code shall be implemented in C++.

 

Code Segment:

#include <iostream>
#include <string>
using namespace std;
string StringFilter( string origin, string filter ){
    string result;
    // Fill in your code here...
    return result;
}

int main(){
    string input;
    string filter;
    while( getline( cin, input ) ){
        getline( cin, filter );
        cout << StringFilter ( input, filter ) << endl;
    }
    return 0;
}
 

Input :

Two lines are a set of input.
The first line is original string.
The second line is the string which you want to filter.

Output :

The output is the filtered string.

Sample Input :

Orange is yummy food
yummy 
I don’t like OOP
don’t 
AAAAAAAAAAAAAAAAB
A
National Ha Ha University
Ha 

Sample Output :

Orange is food
I like OOP
B
National University

Hint :


  

Author :


  Solve it!   Status Forum (0)

C++
C
JAVA
42358. cp99703032 (6 ms , 394KB)
41030. oop100703038 (6 ms , 396KB)
40974. oop100703043 (6 ms , 398KB)
40969. oop100703020 (6 ms , 400KB)
40966. oop98703053 (6 ms , 406KB)
沒有解題記錄 58702. nwgs524513cja (134 ms , 368KB)

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