-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path112a.c
More file actions
48 lines (42 loc) · 709 Bytes
/
112a.c
File metadata and controls
48 lines (42 loc) · 709 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
// A. Petya and Strings
// implementation, strings, *800
#include <stdio.h>
int strcmp(char *s1, char *s2)
{
while (*s1 == *s2++)
if (*s1++ == '\0')
return 0;
return *s1 - *(s2 - 1);
}
void toLowerCase(char *b)
{
for (char *p = b; *p; ++p)
{
if (*p >= 65 && *p <= 90)
{
*p += 32;
}
}
}
int main(void)
{
char b1[101];
char b2[101];
scanf("%100s\n%100s", b1, b2);
toLowerCase(b1);
toLowerCase(b2);
int cmp = strcmp(b1, b2);
if (cmp < 0)
{
printf("%d\n", -1);
}
else if (cmp > 0)
{
printf("%d\n", 1);
}
else
{
printf("%d\n", 0);
}
return 0;
}