判斷字母

 avatar
user_6817964
c_cpp
3 years ago
479 B
4
Indexable
#include <stdio.h> // printf
int main()
{
	char input;
	int eng = 0;
	char x[2][27] = { "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ" };
	scanf(" %c", &input);
	for (int i = 0; i < 26; i++) {
		if (input == x[0][i] || input == x[1][i]) {
			eng = 1;
			if (i == 0)
				printf("the first.");
			else if (i == 25)
				printf("the last.");
			else
				printf("%c%c", x[1][i - 1], x[1][i + 1]);

		}

	}
	if (eng == 0)
		printf("not English.");
}
Editor is loading...