PAT-B1014(C/C++代码解析)

1014 福尔摩斯的约会 (20 分)
PAT-B1014(C/C++代码解析)
注:字符串处理

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main ()
{
	char a[88],b[88],c[88],d[88];
    int i,j;
	char week[7][4]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
	scanf ("%s %s %s %s",a,b,c,d);
	for (i=0;i<min(strlen(a),strlen(b));i++)
	{
		if (a[i]==b[i]&&a[i]>='A'&&a[i]<='G')
		{
			printf ("%s ",week[a[i]-'A']);
			break;
		}
	}
	for (j=i+1;j<min(strlen(a),strlen(b));j++)
	{
		if (a[j]==b[j])
		{
			if (a[j]>='0'&&a[j]<='9')
			{
				printf ("0%d:",a[j]-'0');
				break;
			}
			else if (a[j]>='A'&&a[j]<='N')
			{
				printf ("%d:",a[j]-'A'+10);
				break;
			}
		}
	}
	for (i=0;i<min(strlen(c),strlen(d));i++)
	{
		if (c[i]==d[i]&&((c[i]>='A'&&c[i]<='Z')||(c[i]>='a'&&c[i]<='z')))
		{
			printf ("%02d",i);
		}
	}
	return 0;	
} 
上一篇:表格拼接,融合


下一篇:快排归并梳理