PAT exam 1014 B Holmes Dating

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/a029019/article/details/100587052

PAT exam 1014 B Holmes Dating

topic:

Sherlock Holmes received a strange note: we meet it! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s & hgsfdk d & Hyscvnm. Detective soon realized that actually strange garbled appointments on time Thursday 14:04 note, because the front two in the first string for the same capital letters (case sensitive distinction) is the first four letters D representative Thursday; 2 is the E of the same character, it is the first five letters of the alphabet, the representative day of 14 hours (so one is 0:00 to 23:00 by the numbers 0 to 9, and the capital letters a to N shown); behind the first two for the same string of letters s appear in the 4th position (counting from 0), the representative of the first 4 minutes. Now given two pairs of strings, please help Holmes decoded appointment time.

Input format:
Input line 4 are given in the four non-empty, no spaces, and the length of the string 60 is not exceeded.

Output formats:
Output appointment time in a row, the format DAY HH: MM, which is a week DAY 3 character abbreviation that MON = Monday, TUE for Tuesday, WED for Wednesday, THU expressed Thursday, FRI means that on Friday, SAT for Saturday, SUN for Sunday. Enter the topic guarantee the existence of a unique solution for each test.

Sample input:
3485djDkxh4hhGE
2984akDfkkkkggEdsb
S & hgsfdk
D & Hyscvnm
output sample:
the THU 14:04

This question is a lot of pits, the pit is not so much, as it is the law.
First of all: a week should range between AG, and must be in the same bit;
Second: should be in the range of 0-9 hours between the AN, although the look is not the same one, you play on the same point of view is the one in the example, Therefore hours must also be met in the same place. If less than 10, 0 must be added, for example: 01.
You must set the flag flag, or will the same as the output of other characters.
Finally: minutes lowercase letters can be uppercase letters, but also in the same place, and its output is the number of bits, if less than 10 must add 0.
Look at the code.
Code:

#pragma warning(disable:4996)
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<memory.h>
#include<math.h>


int main(void)
{
	int hour[24] = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 };
	const char* day[7] = { "MON","TUE","WED","THU","FRI","SAT","SUN" };
	int lena = 0, lenb = 0, lenc = 0, lend = 0, i = 0, j = 0, flag = 0;
	char array[61], brrby[61], crrcy[61], drrdy[61];
	scanf("%s", array);
	lena = strlen(array);
	scanf("%s", brrby);
	lenb = strlen(brrby);
	scanf("%s", crrcy);
	lenc = strlen(crrcy);
	scanf("%s", drrdy);
	lend = strlen(drrdy);
	for (i = 0; i < lena; i++)
	{
		for (j = 0; j < lenb; j++)
		{
			if (array[i] == brrby[j] && 65 <= array[i] && array[i] <= 71 && flag == 0 && i == j)
			{
				printf("%s ", day[array[i] - 65]);
				flag++;
				i++;
				j++;
			}
			if (array[i] == brrby[j] && 48 <= array[i] && array[i] <= 57 && flag == 1 && i == j)
			{
				printf("0%d:", hour[array[i] - 48]);
				flag++;
			}
			if (array[i] == brrby[j] && 65 <= array[i] && array[i] <= 78 && flag == 1 && i == j)
			{
				printf("%d:", hour[array[i] - 55]);
				flag++;
			}
		}
	}
	for (i = 0; i < lenc; i++)
	{
		for (j = 0; j < lend; j++)
		{
			if (crrcy[i] == drrdy[j] && 65 <= crrcy[i] && i == j)
			{
				if (i < 10)
				{
					printf("0%d", i);
				}
				else
				{
					printf("%d", i);
				}
				break;
			}
		}
	}
//	array=(int*)malloc(n*(sizeof(int)));
//	free(array);
	return 0;
}

Guess you like

Origin blog.csdn.net/a029019/article/details/100587052