-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtransl.c
More file actions
50 lines (31 loc) · 658 Bytes
/
transl.c
File metadata and controls
50 lines (31 loc) · 658 Bytes
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
#include <stdio.h>
int signdaStr(char *str);
int main()
{
int n,c,i;
char um[4], dois[4], tres[6];
scanf("%d",&n);
getchar();
for (i = 0; i < n; ++i)
{
scanf("%[^\n]%*c",um);
printf("%d\n",signdaStr(um));
}
return 0;
}
int signdaStr(char *str){
char one[]="one";
char two[]="two";
char three[]="three";
char c=0,contone=0,conttwo=0,contthr=0;
for (c = 0; str[c]!='\0' ; ++c)
{
if (str[c]==one[c]) contone++;
if (str[c]==two[c]) conttwo++;
if (str[c]==three[c]) contthr++;
}
if(contone > conttwo && contone > contthr) return 1;
else if (conttwo > contone && conttwo > contthr) return 2;
else
return 3;
}