当前位置:网站首页>Pat class B 1014 C language
Pat class B 1014 C language
2022-06-23 05:54:00 【Octopus bro】
1014. Sherlock Holmes' date (20)
Sherlock Holmes received a strange note :“ let's date !3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm”. The detective soon understood , The strange code on the note is actually the time of the date “ Thursday 14:04”, Because of the first two strings 1 For the same capital letters ( There is a distinction between case and case ) It's No 4 Letters 'D', On behalf of Thursday ; The first 2 For the same character is 'E', That's number one 5 English letters , It's the third day of the day 14 An hour ( So one day 0 Point to 23 Point by number 0 To 9、 And capital letters A To N Express ); After the second string 1 For the same English letters 's' Appear in the 4 A place ( from 0 Start counting ) On , On behalf of the 4 minute . Now give two pairs of strings , Please help Holmes decode the date .
Input format :
Enter in 4 Each line gives 4 One is not empty 、 No spaces 、 And the length shall not exceed 60 String .
Output format :
Output the appointment time in one line , The format is “DAY HH:MM”, among “DAY” It's a week's 3 Character abbreviations , namely MON For Monday ,TUE For Tuesday ,WED It means Wednesday ,THU It means Thursday ,FRI It means Friday ,SAT For Saturday ,SUN Means Sunday . Topic input ensures that each test has a unique solution .
sample input :3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnmsample output :
THU 14:04
Ideas : Set the week first : Find... In the first line of the string ‘A’-‘G’ The characters of , And the character at the same position as the second line , If equal, determine the week . Determine the hour , Continue to look backwards for numbers or... Based on the characters of the week ‘A’-‘N’ The letter of , Compare with the characters in the same position on the second line . Set the minutes , Look for the letters that appear in the third line of the string , Compare with the characters in the same position on the fourth line , Be careful , Here is the location .
One 、 Starting variable
1.a、b、c、d Four strings
2.count, Count variables , Used to determine which character is the same .
Two 、 operation
1. Set the week first : Find... In the first line of the string ‘A’-‘G’ The characters of , And the character at the same position as the second line , If equal, determine the week .
2. Determine the hour , Continue to look backwards for numbers or... Based on the characters of the week ‘A’-‘N’ The letter of , Compare with the characters in the same position on the second line .
3. Set the minutes , Look for the letters that appear in the third line of the string , Compare with the characters in the same position on the fourth line , Be careful , Here is the location .
3、 ... and 、 Code
#include "stdio.h"
#include "string.h"
typedef char String[4];
int main()
{
String week[7] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
char a[60],b[60],c[60],d[60];
int i, j;
int count = 0;// It is used to count the number of the same characters ;
scanf("%s",a);
scanf("%s",b);
scanf("%s",c);
scanf("%s",d);
for(i = 0; i < strlen(a) && count <= 1; i++)
{
// Determine week : Find... In the first line of the string ‘A’-‘G’ The characters of , And the character at the same position as the second line , If equal, determine the week .
if(count == 0 && a[i] >= 'A' && a[i] <= 'G' )
{
if(a[i] == b[i])
{
int num = a[i] - 'A';
printf("%s ",week[num]);
i++;
count++;
}
}
// Determine the hour , Continue to look backwards for numbers or... Based on the characters of the week ‘A’-‘N’ The letter of , Compare with the characters in the same position on the second line .
if(count == 1 && a[i] >= '0' && a[i] <= '9' )
{
if(a[i] == b[i])
{
printf("0%d:",a[i] - '0');
break;
}
}
else if(count == 1 && a[i] >= 'A' && a[i] <= 'N' )
{
if(a[i] == b[i])
{
printf("%d:",a[i] - 55);
break;
}
}
}
// Set the minutes , Look for the letters that appear in the third line of the string , Compare with the characters in the same position on the fourth line , Be careful , Here is the location .
for( i = 0; i < strlen(c); i++)
{
if((c[i] >= 'a' && c[i] <= 'z') || (c[i] >= 'A' && c[i] <= 'Z'))
{
if(c[i] == d[i])
{
if(i < 10)
{
printf("0%d",i);
break;
}
else
{
printf("%d",i);
break;
}
}
}
}
return 0;
}边栏推荐
- True MySQL interview question (XXII) -- condition screening and grouping screening after table connection
- C prime plus notes d'apprentissage - 2, constantes et formatage io (I / o)
- How to move the software downloaded from win11 app store to the desktop
- Adnroid activity截屏 保存显示到相册 View显示图片 动画消失
- What is the magic of digital collections? Which reliable teams are currently developing
- PAT 乙等 1026 程序运行时间
- Leetcode topic analysis: factorial training zeroes
- Analysis on the problems and causes of digital transformation of manufacturing industry
- Mobile power fast charging qc3.0 scheme chip ip5318 fast charging scheme
- The digital collection market has just begun
猜你喜欢

Raspberry pie assert preliminary exercise

Wechat applet; AI intelligent dubbing assistant

Yingjixin ip6806 wireless charging scheme 5W Qi certified peripheral simplified 14 devices

Software design and Development Notes 2: serial port debugging tool based on QT design

Arctime makes Chinese and English subtitle video

Huawei's software and hardware ecosystem has taken shape, fundamentally changing the leading position of the United States in the software and hardware system

Digital collections - new investment opportunities

Deploy docker and install MySQL in centos7

Three most advanced certifications, two innovative technologies and two outstanding cases, Alibaba cloud appeared at the cloud native industry conference

Management system of borrowed books based on SSM framework
随机推荐
Software design and Development Notes 2: serial port debugging tool based on QT design
技术开发团队视角看到的数字藏品机遇与挑战
[proteus simulation] Arduino uno+pcf8574+lcd1602+mpx4250 electronic scale
Excel sheet column title for leetcode Title Resolution
JS面试题----防抖函数
Behind the hot digital collections, a strong technical team is needed to support the northern technical team
PAT 乙等 1017 C语言
Lottery DDD code
PAT 乙等 1009 C语言
Wechat applet: Puzzle toolbox
C primer plus学习笔记 —— 2、常量与格式化IO(输入/输出)
MySQL character set
MySQL面试真题(二十九)——案例-找到爱看的电影
Basic calculator for leetcode topic analysis
New classes are launched | 5 minutes each time, you can easily play with Alibaba cloud container service!
PAT 乙等 1026 程序运行时间
[graduation season u; advanced technology Er] farewell to the confused self in the past two years. Regroup, junior I'm coming
Dolphin scheduler dolphin scheduling upgrade code transformation -upgradedolphin scheduler
node中操作mongoDB
How does win11 enable mobile hotspot? How to enable mobile hotspot in win11