o.boj 1081 Bovine Latin

本文介绍了一个将英文单词转换为Bovine Latin的简单程序。该程序接收一系列英文单词作为输入,并根据特定规则将其转化为Bovine Latin形式。文章包含完整的C++代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

注:最近这一系列ACM的内容,都是2年多之前的代码,自己回顾一下。

 

 

Bovine Latin

                  
Submit: 947 Accepted:514
Time Limit: 1000MS Memory Limit: 65536K

Description

The cows have heard that the pigs use a secret language called "Pig Latin" when they want to communicate with each other without Farmer John being able to understand what they are saying. Thinking this is an excellent idea, they have invented their own version, aptly called Bovine Latin.
Converting an English word to a Bovine Latin word is quite simple. For words that start with a vowel ('a', 'e', 'i', 'o' or 'u'), "cow" is added to the end of the word; for example, "udder" becomes "uddercow". For words that do not begin with a vowel, the first letter is moved to the end of the word, and "ow" is added; e.g., "farmer" becomes "armerfow". So "the cows escape at dawn" becomes "hetow owscow escapecow atcow awndow." The cows fervently believe that FJ will not understand this subterfuge.
 
Never known as enthusiastic linguists, the cows find this translation quite tedious and thus have asked you to write a program that will take single words and translate them into Bovine Latin. They will provide you with N (1 <= N <= 100) words to translate; word lengths range from 3 to 40 letters.
 
 

Input

* Line 1: A single integer: N
* Lines 2..N+1: One word per line.
 
 

Output

* Lines 1..N: The Bovine Latin translations of the given words
 
 

Sample Input

 
5
udder
farmer
milk
aaa
zzz
 
 

Sample Output

 
uddercow
armerfow
ilkmow
aaacow
zzzow
 
 

Source

USACO MAR07 BRONZE Division

 


简单的模拟题


#include <iostream>
#include <string>

using namespace std;

int main()
{
    string S[105];
    int N;
    char ch;
    
    cin >> N;
    
    for (int i = 0; i < N; i++)
        cin >> S[i];
    
    for (int i = 0; i < N; i++)
    {
        if (S[i][0] == 'a' || S[i][0] == 'e' || S[i][0] == 'i' ||
           S[i][0] == 'o' || S[i][0] == 'u' )
            cout << S[i] << "cow" << endl;
        else
        {
            ch = S[i][0];
            S[i].replace(0, 1, "");
            S[i].insert(S[i].end(), ch);
            cout << S[i] << "ow" << endl;       
        }
    }
    // system("pause");
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值