-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path657_JRC.c
More file actions
40 lines (40 loc) · 767 Bytes
/
657_JRC.c
File metadata and controls
40 lines (40 loc) · 767 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
#include "apue.h"
#include <stdbool.h>
#define true 1
#define false 0
bool judgeCircle(char* moves) {
int x = 0;
int y = 0;
char *i = moves;
for (; *i != '\0'; i++)
{
switch(*i)
{
case 'U':
y++;
break;
case 'D':
y--;
break;
case 'L':
x++;
break;
case 'R':
x--;
break;
default:
break;
}
}
printf("%d,%d\n", x, y);
return x == 0 && y ==0;
}
int main(void)
{
char str[] = "UD";
if (judgeCircle(str) == true)
printf("True\n");
else
printf("False\n");
return 0;
}