判斷字母

 avatar
user_3763047219
c_cpp
2 years ago
767 B
4
Indexable
#include <stdio.h>
int main()
{
	char text,count=0;
	char ABC[28] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\0";
	char abc[28] = "abcdefghijklmnopqrstuvwxyz\0";
	scanf(" %c", &text);

	for (int i = 0;i < 26;i++) {
		if (text == abc[i]) {
			if (i == 0) {
				count = 1;
				printf("the first.");
			}
			else if (i == 25) {
				count = 1;
				printf("the last.");
			}
			else {
				count = 1;
				printf("%c%c", ABC[i - 1], ABC[i + 1]);
			}
		}
		else if (text == ABC[i]) {
			if (i == 0) {
				count = 1;
				printf("the first.");
			}
			else if (i == 25) {
				count = 1;
				printf("the last.");
			}
			else {
				count = 1;
				printf("%c%c", ABC[i - 1], ABC[i + 1]);
			}
		}
	}
	if (count == 0) {
		printf("not English.");
	}

}
Editor is loading...