forked from malbolgee/URI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1140.c
71 lines (47 loc) · 1004 Bytes
/
1140.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
@autor: Malbolge;
@data: 04/11/2018;
@nome: Flores Florescem da França;
*/
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
typedef struct{
char palavra[21];
} string;
bool isTautograma(string *, unsigned short tam);
void main ()
{
unsigned short i;
while (true)
{
char frase[2000] = { 0 }, *palavraTmp;
string palavras[100];
scanf(" %[^\n]", frase);
if (strcmp(frase, "*") == 0)
break;
i = 0;
palavraTmp = strtok(frase, " ");
strcpy(palavras[i++].palavra, palavraTmp);
do
{
palavraTmp = strtok('\0', " ");
if (palavraTmp)
strcpy(palavras[i++].palavra, palavraTmp);
} while (palavraTmp);
// Resultado final;
if (isTautograma(palavras, i))
printf("Y\n");
else
printf("N\n");
}
}
bool isTautograma(string *palavras, unsigned short tam)
{
unsigned short i;
for (i = 1; i < tam; i++)
if (tolower(palavras[i].palavra[0]) != tolower(palavras[i - 1].palavra[0]))
return false;
return true;
}