본문 바로가기

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

OJ 1195

반응형
 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
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char word[20][100];

int main(void)
{
	int n;
	scanf("%d", &n);

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

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i-1; j++)
		{
			if (strcmp(word[j], word[j + 1]) > 0)
			{
				char temp[100];
				strcpy(temp, word[j]);
				strcpy(word[j], word[j + 1]);
				strcpy(word[j + 1], temp);
			}
		}
	}

	for (int i = 0; i < n; i++)
	{
		printf("%s\n", word[i]);
	}

	return 0;
}
반응형

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

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