10361 - Automatic Poetry

#include<iostream>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;

char str1[105],str2[105];
string s2,s4;

int main(){
    int n;
    cin >> n;
    getchar();
    while(n--){
        gets(str1);
        gets(str2);
        s2 = "";
        s4 = "";
        int cnt = 0;
        int pos1,pos2;
        for(int i = 0; i < strlen(str1); i++)
        {
            int j;
            if(str1[i] == ‘<‘){
                if(!cnt){
                    for(j = i+1; str1[j] != ‘>‘; j++)
                    s2 += str1[j];                   //求s2
                    pos1 = j + 1;                    //记录s3起始位置
                    cnt ++;
                }else{
                    for(j = i+1; str1[j] != ‘>‘; j++)
                        s4 += str1[j];              //求s4
                    pos2 = j + 1;                    //记录s4起始位置
                }
            }
            if(!(str1[i] == ‘<‘ || str1[i] == ‘>‘))
                cout << str1[i];
        }
        cout << endl;

        for(int i = 0; i< strlen(str2) - 3; i++)
            cout << str2[i];
        cout << s4;
        for(int i = pos1; str1[i] != ‘<‘;i++)
            cout << str1[i];
        cout << s2;
        for(int i = pos2; str1[i] != ‘\0‘;i++)
            cout << str1[i];
        cout << endl;
    }

    return 0;
}
时间: 2024-11-10 10:49:44

10361 - Automatic Poetry的相关文章

UVA之10361 - Automatic Poetry

Problem I Automatic Poetry Input: standard input Output: standard output Time Limit: 2 seconds Memory Limit: 32 MB "Oh God", Lara Croft exclaims, "it's one of these dumb riddles again!" In Tomb Raider XIV, Lara is, as ever, gunning her

UVa 10361 Automatic Poetry

Automatic Poetry Input: standard input Output: standard output Time Limit: 2 seconds Memory Limit: 32 MB “Oh God”, Lara Croft exclaims, “it’s one of these dumb riddles again!” In Tomb Raider XIV, Lara is, as ever, gunning her way through ancient Egyp

小白书训练-Automatic Poetry

题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1302 题意:就是用<和>吧一句话截断为5部分,然后先打印s1s2s3s4s5,然后再输入一句话,然后在打印这句话(去除'.'),然后打印s4s3s2s5.其实就是个模拟,没有难度,就是英语有点问题,用指针分分钟的事情. 代码: #include <iostream

UVA题目分类

题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes

UVA 10361-Automatic Poetry(模拟)

Automatic Poetry Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Description Problem I Automatic Poetry Input: standard input Output: standard output Time Limit: 2 seconds Memory Limit: 32 MB "Oh God", La

UVA10361 -自动作诗机

UVA10361 - Automatic Poetry(自动作诗机) A Schuttelreim seems to be a typical German invention. The funny thing about this strange type of poetry is that if somebody gives you the first line and the beginning of the second one, you can complete the poem yo

Automatic logon configuration on Linux OS

Automatic logon configuration on Linux OS 1. Regarding to DSA: a) ssh-keygen -t dsa b) cat ~/.ssh/id_dsa.pub | ssh <username>@<remote-host> "cat - >> ~/.ssh/authorized_keys" 2. Regarding to RSA: a) ssh-keygen -t rsa b) ssh-copy

FAQ: Automatic Statistics Collection (文档 ID 1233203.1)

In this Document   Purpose   Questions and Answers   What kind of statistics do the Automated tasks collect   How do I revert to a previous set of statistics?   Does the automatic statistic collection jobs populate CHAIN_CNT?   11g+ Automatic Mainten

RDBMS and listener log (xml) from SQL*Plus with V$DIAG_ALERT_EXt view [ADR - Automatic Diagnostic Re

With the V$DIAG_ALERT_EXT it is possible to read the logs of all the databases and listeners from the ADR location Great for monitoring. Now only one connection to a database is needed to see all the database alert files and listener logs registered