-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12-4.c
More file actions
40 lines (33 loc) · 864 Bytes
/
12-4.c
File metadata and controls
40 lines (33 loc) · 864 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
//키보드로 세 단어 입력하면 사전 순서대로 출력하는 프로그램
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
void swap (char* str1, char* str2, char* str3)
{
char temp[80];
if (strcmp(str1, str2) > 0) {
strcpy(temp, str1);
strcpy(str1, str2);
strcpy(str2, temp);
}
if (strcmp(str1, str3) > 0) {
strcpy(temp, str1);
strcpy(str1, str3);
strcpy(str3, temp);
}
if (strcmp(str2, str3) > 0) {
strcpy(temp, str2);
strcpy(str2, str3);
strcpy(str3, temp);
}
}
int main (void)
{
char str1[80], str2[80], str3[80];
printf("세 단어 입력 : ");
scanf("%s %s %s", str1, str2, str3);
swap(str1, str2, str3);
printf("사전순 정렬 : ");
printf("%s %s %s \n", str1, str2, str3);
return 0;
}