PTA 乙级 1014 福尔摩斯的约会

代码实现:

#include
#include

int main(void)
{
	char ch1[61], ch2[61], ch3[61], ch4[61];
	int i, judge1 = 0, judge2 = 0, judge3 = 0;

	scanf("%s %s %s %s", ch1, ch2, ch3, ch4);
	for (i = 0; i <= strlen(ch1) && i <= strlen(ch2); i++)
	{
		if (judge1 != 0 && ch1[i] == ch2[i] && judge2 == 0)
		{
			if (ch1[i] >= '0'&&ch1[i] <= '9')
			{
				printf("0%c:", ch1[i]);
				judge2 = 1;
			}
			else if (ch1[i] >= 'A'&&ch1[i] <= 'N')
			{
				printf("%d:", ch1[i] - 55);
				judge2 = 1;
			}
		}
		if (ch1[i] == ch2[i] && ch1[i] >= 'A'&&ch1[i] <= 'G'&&judge1 == 0)
		{
			switch (ch1[i])
			{
			case 'A':printf("MON "); break;
			case 'B':printf("TUE "); break;
			case 'C':printf("WED "); break;
			case 'D':printf("THU "); break;
			case 'E':printf("FRI "); break;
			case 'F':printf("SAT "); break;
			case 'G':printf("SUN "); break;
			default:
				break;
			}
			judge1 = 1;
		}
	}
	for (i = 0; i <= strlen(ch3) && i <= strlen(ch4); i++)
	{
		if (ch3[i] == ch4[i] && ((ch3[i] >= 'a'&&ch3[i] <= 'z') || (ch3[i] >= 'A'&&ch3[i] <= 'Z')))
		{
			if (i < 10)
				printf("0%d\n", i);
			else if (i >= 10)
				printf("%d\n", i);
		}
	}

	return 0;
}

你可能感兴趣的:(PTA,Basic,Level,Practice)