-
Notifications
You must be signed in to change notification settings - Fork 0
/
GM.c
37 lines (35 loc) · 890 Bytes
/
GM.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
#include <stdio.h>
int main()
{
printf("Tell the current position of player? (You are allowed to only input a character)\nThen input the no. of moves.\n");
char position;
//filtering positions
do {
scanf("%c", &position);
}
while (!(position >= 65 && position <= 90 || position >= 97 && position <= 122));
int moves;
scanf("%d", &moves);
//filtering moves
moves = moves % 26;
printf("Final position of the player is\n");
//Applying the game algorithm
if (position <= 90 && position >= 65)
{
position += moves;
if (position > 90)
{
position -= 26;
}
printf("%c", position);
}
else
{
position += moves;
if (position > 122)
{
position -= 26;
}
printf("%c", position);
}
}