-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathh02ex03.c
More file actions
49 lines (47 loc) · 846 Bytes
/
Copy pathh02ex03.c
File metadata and controls
49 lines (47 loc) · 846 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
#include <stdio.h>
#include <stdlib.h>
void AlphaSort(char s[])
{
int b = 0;
int i = 0;
while (s[i] != '\0')
{
if (s[i] == ' ')
{
b = i;
while (s[b] != '\0')
{
if (b != i)
{
s[b - 1] = s[b];
}
b++;
}
if (b != i)
s[b - 1] = '\0';
}
i++;
}
printf("%d\n", i);
int j, k;
char temp;
for (j = 0; j < i; j++)
{
for (k = j + 1; k < i; k++)
{
if (s[j] > s[k])
{
temp = s[j];
s[j] = s[k];
s[k] = temp;
}
}
}
}
int main()
{
char s[] = "bacedgf ihkj";
AlphaSort(s);
printf("%s\n", s);
return 0;
}