본문 바로가기

C언어프로그래밍/소스코드

OJ 1194

반응형
 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
72
73
74
75
76
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

int main(void)
{
	int alphacount[26] = { 0 };

	int momax = -1000000;
	int jamax = -1000000;
	int moumindex = -1;
	int jaumindex = -1;
	int n;
	char a[100][100];

	scanf("%d", &n);


	for (int i = 0; i < n; i++)
	{
		scanf("%s", a[i]);
	}


	for (int k = 0; k < n; k++)

	{
		for (int j = 0; j < strlen(a[k]); j++)
		{
			a[k][j] = tolower(a[k][j]);
			alphacount[a[k][j] - 'a']++;
		}
	}


	for (int e = 0; e < 26; e++)
	{

		if (e == 0 || e == 'e' - 'a' || e == 'i' - 'a' || e == 'o' - 'a' || e == 'u' - 'a')
		{



			if (momax < alphacount[e])
			{
				momax = alphacount[e];

				moumindex = e + 'a';

			}

		}



		else
		{


			if (jamax < alphacount[e])
			{
				jamax = alphacount[e];

				jaumindex = e + 'a';

			}

		}
	}

	printf("%c %c", jaumindex, moumindex);

	return 0;

}
반응형

'C언어프로그래밍 > 소스코드' 카테고리의 다른 글

OJ 1193  (0) 2016.06.08
OJ 1195  (0) 2016.06.08
바이오리듬 프로그램  (0) 2016.05.26
OJ 1184 모기, 지카바이러스 문제 답  (0) 2016.05.17
OJ 1173  (0) 2016.04.25