-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp04ex11.c
68 lines (59 loc) · 792 Bytes
/
p04ex11.c
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
/*** p04ex11.c ***/
/*** ps20 ***/
#include <stdio.h>
int main()
{
char x[1024];
char y[1024];
int flag = 0;
int i, j, k;
printf("str1 = ");
gets(x);
printf("str2 = ");
gets(y);
j = 0;
k = 0;
while (x[j] != '\0')
{
j++;
}
while (y[k] != '\0')
{
k++;
}
if (j != k)
{
printf("%s %s => not equal", x, y);
return 0;
}
for (i = 0; i < j; i++)
{
if (x[i] != y[i])
{
flag = 1;
}
}
if (flag == 0)
{
printf("%s %s => equal", x, y);
}
else
{
printf("%s %s => not equal", x, y);
}
return 0;
}
/*** 結果 ***
str1 = robot
str2 = robotics
robot robotics => not equal
str1 = robotics
str2 = robot
robotics robot => not equal
str1 = robot
str2 = robot
robot robot => equal
str1 = time
str2 = game
time game => not equal
*************/