回分類題庫
d159: OOP Lab Exercise: Acronym
出處:

Difficulity : 1
Accepted : 93 Times | Submit :135 Times | Clicks : 1785
Accepted : 87 Users | Submit : 93 Users | Accepted rate : 94%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2010-03-02 15:51

Content :

An acronym is a word formed by taking the first letter of each word in a sequence, as in "self contained underwater breathing apparatus" -> "scuba".

Your task is to write a C++ program to generate acronym.

Luckily we provide a code segment which deal with the continue input and a function for you to implement in class.

In this code, function "acronym" take a string as input and output its acronym as a string.
For example, if input is "Hello World", then the output is "HW".

Note that there is no newline generated by this function. 

Remember your code shall be implemented in C++.

 

#include <iostream>
#include <string>

using namespace std;

string acronym(string str){
    string result;
    //  Fill in your code here...

    return result;
}

int main(){
    string input;

    while(getline(cin, input)){
        cout << acronym(input) << endl;
    }
    return 0;
}

Input :

There are multiple lines of input, each line is a set. For each set, generate its acronyms. Please refer to the sample input.

Output :

Each line is an set of output of the coordinate acronyms. Please refer to the sample output.

Sample Input :

Generation Unrestricted Network Drive Assault Module
Kaohsiung Senior High School
National Ha Ha University
I See You

Sample Output :

GUNDAM
KSHS
NHHU
ISY

Hint :


  

Author :


  Solve it!   Status Forum (0)

C++
C
JAVA
24421. leopan0922 (2 ms , 316KB)
18407. icelorc (2 ms , 392KB)
56498. johnny (4 ms , 196KB)
22375. oop98703012 (4 ms , 396KB)
18635. oop98703055 (4 ms , 384KB)
56439. ag100 (2 ms , 190KB)
18498. yuhanlyu (2 ms , 172KB)
18500. Tc (4 ms , 172KB)
87057. nccucs105703018 (8 ms , 164KB)
78171. bello6110 (8 ms , 162KB)
50689. nwgs524513cja (106 ms , 164KB)

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