[UVA][字串] 10197 - Learning Portuguese
Problem D: Learning Portuguese
Problem D: Learning Portuguese |
The Problem
Portuguese is one of the most beautiful languages in the whole world, but almost everyone who speaks Portuguese is either brazilian or portuguese. Since people all around the world (and not just brazilians) are participating in this contest, we would like to help you to begin learning portuguese with this problem. Well, the program you'll write will help you (if it's correct).
All you must to do is to write a conjugator, that is, a program that conjugates verbs. In English there's not much to do when the verb is "regular" (it follows some model). But in Portuguese it's a bit different. But don't worry, we'll explain all you need to know in order to learn how to conjugate regular portuguese verbs.
First of all, let's learn the pronouns, which you'll use to conjugate the verbs:
English | Portuguese |
I | Eu |
You | Tu |
He/She | Ele/Ela |
We | Nós |
You | Vós |
They | Eles/Elas |
The "ó" character is represented by ASCII code 243. It doesn't matter how it looks on your screen, use ASCII character 243 when writing "n�s" and "v�s"! In Portuguese, all verbs in the infinitive mode have one of these sufixes: ar (first conjugations), er (second conjugation) and ir (third conjugation). For instance, "amar" (to love) is from the first conjugation, whereas "correr" (to run) is from the second, and "partir" (to go away) is from the third. So, you can recognize from which conjugations is the verb by its sufix (of course there are some exceptions to this rules, but we're not going to handle them).
We call "root" the verb in the infinitive mode without the sufix (so, for these three verbs we just saw, we have "am", "corr" and "part" as roots). We call the "thematic vowel" (tv for short) the vowel of the sufix (i.e. "a", "e" or "i").
To conjugate regular verbs, all you have to do is to find out from which conjugations is the verb and, then, follow the model for that conjugation. In this problem we are only interested in the "presente tense", so here are the models for all conjugations on the presente tense:
Pronoun | 1st Conjugation | 2nd Conjugation | 3rd Conjugation |
Eu | root + o | root + o | root + o |
Tu | root + tv + s | root + tv + s | root + es |
Ele/Ela | root + tv | root + tv | root + e |
Nós | root + tv + mos | root + tv + mos | root + tv + mos |
Vós | root + tv + is | root + tv + is | root + tv + s |
Eles/Elas | root + tv + m | root + tv + m | root + em |
Let's see, as an example, the conjugation of the three verbs above:
Pronoun | amar | correr | partir |
Eu | amo | corro | parto |
Tu | amas | corres | partes |
Ele/Ela | ama | corre | parte |
Nós | amamos | corremos | partimos |
Vós | amais | correis | partis |
Eles/Elas | amam | correm | partem |
So, your task is: given a verb in Portuguese (and its meaning in English), conjugate the verb.
The Input
There will be two words per line, v1 and v2. The first one (v1) is the verb in Portuguese, and the second one (v2) is its meaning in English. All words will be formed by just latin lowercase letters (i.e. all letters will lie in the range [a..z]). No word will have more than 30 characters. You must read until you reach the end of file.
The Output
For each pair of words, the first line of output must be:
v1 (to v2)Where v1 stands for the verb in Portuguese and v2 its meaning in English (as described above). After that, you must print 6 lines with the correct conjugation, assuming the verb will be regular. The first character of the pronoun must start at the first column of the line. The equivalent conjugation to that pronoun must begin at column 11 of the same line. The space between the pronoun and the conjugation must be filled with blanks. If the verb read lies in none of the conjugations given, instead of the conjugation, just print the line
Unknown conjugationYou must print a blank line between the output sets.
Sample Input
falar talk compor compose andar walk
Sample Output
falar (to talk) eu falo tu falas ele/ela fala n�s falamos v�s falais eles/elas falam compor (to compose) Unknown conjugation andar (to walk) eu ando tu andas ele/ela anda n�s andamos v�s andais eles/elas andam
© 2001 Universidade do Brasil (UFRJ). Internal Contest 2001.
有點麻煩的葡萄牙語, 跟著處理一下後綴即可。
#include <stdio.h>
#include <string.h>
int main() {
char s1[105], s2[105];
int cases = 0;
while(scanf("%s %s", s1, s2) == 2) {
if(cases) puts("");
cases++;
printf("%s (to %s)\n", s1, s2);
int len = strlen(s1);
if(len < 2 || (strcmp(s1+len-2, "ar") && strcmp(s1+len-2, "er")
&& strcmp(s1+len-2, "ir"))) {
puts("Unknown conjugation");
continue;
}
int tv = s1[len-2];
s1[len-2] = '\0';
printf("eu %so\n", s1);
if(tv == 'i')
printf("tu %ses\n", s1);
else
printf("tu %s%cs\n", s1, tv);
if(tv == 'i')
printf("ele/ela %se\n", s1);
else
printf("ele/ela %s%c\n", s1, tv);
printf("n%cs %s%cmos\n", (unsigned char)243, s1, tv);
if(tv == 'i')
printf("v%cs %s%cs\n", (unsigned char)243, s1, tv);
else
printf("v%cs %s%cis\n", (unsigned char)243, s1, tv);
if(tv == 'i')
printf("eles/elas %sem\n", s1);
else
printf("eles/elas %s%cm\n", s1, tv);
}
return 0;
}