URI Online Judge | 1332
Um-Dois-Três
Por Rujia Liu
China
Timelimit: 1
China
Seu irmão mais novo aprendeu a escrever apenas um, dois e três, em Inglês. Ele escreveu muitas dessas palavras em um papel e a sua tarefa é reconhecê-las. Nota-se que o seu irmão mais novo é apenas uma criança, então ele pode fazer pequenos erros: para cada palavra, pode haver, no máximo, uma letra errada. O comprimento de palavra é sempre correto. É garantido que cada palavra que ele escreveu é em letras minúsculas, e cada palavra que ele escreveu tem uma interpretação única.
Entrada
A primeira linha contém o número de palavras que o seu irmão mais novo escreveu. Cada uma das linhas seguintes contém uma única palavra com todas as letras em minúsculo. As palavras satisfazem as restrições acima: no máximo uma letra poderia estar errada, mas o comprimento da palavra está sempre correto. Haverá, no máximo, 1000 palavras de entrada.
Saída
Para cada caso de teste, imprima o valor numérico da palavra.
URI Online Judge | 1332
One-Two-Three
By Rujia Liu
China
Timelimit: 1
China
Your little brother has just learnt to write one, two and three, in English. He has written a lot of those words in a paper, your task is to recognize them. Note that your little brother is only a child, so he may make small mistakes: for each word, there might be at most one wrong letter. The word length is always correct. It is guaranteed that each letter he wrote is in lower-case, and each word he wrote has a unique interpretation.
Input
The first line contains the number of words that your little brother has written. Each of the following lines contains a single word with all letters in lower-case. The words satisfy the constraints above: at most one letter might be wrong, but the word length is always correct. There will be at most 1000 words in the input.
Output
For each test case, print the numerical value of the word.
#include <stdio.h>
#include <string.h>
int main ()
{
int testCase; scanf ("%d", &testCase);
while ( testCase-- )
{
char a [10]; scanf ("%s", a);
if ( strlen (a) == 5 ) printf ("3\n");
else
{
int cnt = 0;
if ( a [0] == 'o' ) cnt++;
if ( a [1] == 'n' ) cnt++;
if ( a [2] == 'e' ) cnt++;
if ( cnt >= 2 ) printf ("1\n");
else printf ("2\n");
}
}
return 0;
}
Nenhum comentário:
Postar um comentário