UVA620 Cellular Structure文本处理

Posted 海岛Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA620 Cellular Structure文本处理相关的知识,希望对你有一定的参考价值。

A chain of connected cells of two types A and B composes a cellular structure of some microorganisms of species APUDOTDLS.
    If no mutation had happened during growth of an organism, its cellular chain would take one of the following forms:
• simple stage O = A
• fully-grown stage O = OAB
• mutagenic stage O = BOA
    Sample notation O = OA means that if we added to chain of a healthy organism a cell A from the right hand side, we would end up also with a chain of a healthy organism. It would grow by one cell A.
    A laboratory researches a cluster of these organisms. Your task is to write a program which could find out a current stage of growth and health of an organism, given its cellular chain sequence.
Input
A integer n being a number of cellular chains to test, and then n consecutive lines containing chains of tested organisms.
Output
For each tested chain give (in separate lines) proper answers:
SIMPLE for simple stage
FULLY-GROWN for fully-grown stage
MUTAGENIC for mutagenic stage
MUTANT any other (in case of mutated organisms)
    If an organism were in two stages of growth at the same time the first option from the list above should be given as an answer.
Sample Input
4
A
AAB
BAAB
BAABA
Sample Output
SIMPLE
FULLY-GROWN
MUTANT
MUTAGENIC

问题链接UVA620 Cellular Structure
问题简述:(略)
问题分析:文本处理问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C语言程序如下:

/* UVA620 Cellular Structure */

#include <stdio.h>
#include <string.h>

char s[1024];
const char *p[] = {"NUTANT", "SIMPLE", "MUTAGENIC", "FULLY-GROWN", "MUTANT"};

int main()
{
    int n;
    scanf("%d", &n);
    while (n--) {
        scanf("%s", s);

        int len = strlen(s), ans;
        if ((len & 1) == 0) ans = 0;
        else if (len == 1)
            ans = s[0] == 'A' ? 1 : 0;
        else {
            if (s[0] == 'B' && s[len - 1] == 'A')
                ans = 2;
            else if (s[len - 1] == 'B' && s[len - 2] == 'A')
                ans = 3;
            else
                ans = 4;
        }

        puts(p[ans]);
    }

    return 0;
}

以上是关于UVA620 Cellular Structure文本处理的主要内容,如果未能解决你的问题,请参考以下文章

UVA 1386 Cellular Automaton

uva 11995 I Can Guess the Data Structure!

Uva 11995 I Can Guess the Data Structure!

uva 11995 I Can Guess the Data Structure!

UVA11995 I Can Guess the Data Structure!

UVa 11995 - I Can Guess the Data Structure!