PAT (Advanced Level) 1061. Dating (20)

简单模拟。

#include<stdio.h>
#include<string.h>

char s1[70],s2[70],s3[70],s4[70];
char f[7][5]={"MON ", "TUE ","WED ","THU ","FRI ","SAT ","SUN "};
int a,b,c,flag;

int main()
{
    scanf("%s%s%s%s",s1,s2,s3,s4); flag=0;
    for(int i=0;s1[i]&&s2[i];i++) {
        if(s1[i]!=s2[i]) continue;
        if(flag==0) {if(s1[i]>=‘A‘&&s1[i]<=‘G‘) a=s1[i]-‘A‘+1,flag=1;}
        else if(flag==1){
            if(s1[i]>=‘0‘&&s2[i]<=‘9‘) b=s1[i]-‘0‘,flag=2;
            else if(s1[i]>=‘A‘&&s2[i]<=‘N‘) b=s1[i]-‘A‘+10,flag=2;
        }
    }
    for(int i=0;s3[i]&&s4[i];i++){
        if(s3[i]==s4[i]&&(s3[i]>=‘a‘&&s3[i]<=‘z‘)||(s3[i]>=‘A‘&&s3[i]<=‘Z‘)) {
            c=i;break;
        }
    }
    printf("%s%02d:%02d\n",f[a-1],b,c);
    return 0;
}
时间: 2024-10-10 11:47:42

PAT (Advanced Level) 1061. Dating (20)的相关文章

PAT (Advanced Level) 1077. Kuchiguse (20)

最长公共后缀.暴力. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #include<map> #include<stack> #include<queue> #include<string> #include<algorithm> using namespace std; char s[200][300];

PAT (Advanced Level) 1008. Elevator (20)

简单模拟. 注意a[i]==a[i-1]的情况. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<vector> using namespace std; const int maxn=100+10; int n,a[maxn]; int main() { scanf("%d&

Pat(Advanced Level)Practice--1016(Phone Bills)

Pat1016代码 题目描述: A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a lon

Pat(Advanced Level)Practice--1043(Is It a Binary Search Tree)

Pat1043代码 题目描述: A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes

Pat(Advanced Level)Practice--1044(Shopping in Mars)

Pat1044代码 题目描述: Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any position for only once and some of the diam

PAT (Advanced Level) 1093. Count PAT&#39;s (25)

预处理每个位置之前有多少个P,每个位置之后有多少个T. 对于每个A,贡献的答案是这个A之前的P个数*这个A之后T个数. #include<cstdio> #include<cstring> long long MOD=1e9+7; const int maxn=1e5+10; long long dp1[maxn],dp2[maxn]; char s[maxn]; int main() { scanf("%s",s); memset(dp1,0,sizeof d

PAT (Advanced Level) 1055. The World&#39;s Richest (25)

排序.随便加点优化就能过. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> #include<cstdio> #include<map> #include<queue> #include<string> #include<stack> #include<vector> using names

Pat(Advanced Level)Practice--1018(Public Bike Management)

Pat1018代码 题目描述: There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the city. The Public Bike Management C

Pat(Advanced Level)Practice--1076(Forwards on Weibo)

Pat1076代码 题目描述: Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a user makes a post on Weibo, all hi