1 Star 0 Fork 0

hsmath/PAT advanced

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
1061.cpp 1.24 KB
一键复制 编辑 原始数据 按行查看 历史
Shuang Hu 提交于 2021-03-22 19:29 . My patest code
#include <iostream>
#include <string>
using namespace std;
int min(int a,int b){
if(a<b){
return a;
}else{
return b;
}
}
int main(){
string d1;
string d2;
string m1;
string m2;
cin>>d1;
cin>>d2;
cin>>m1;
cin>>m2;
int date;
int hour;
int minute;
int len1=min(d1.length(),d2.length());
int len2=min(m1.length(),m2.length());
int type=0;
for(int i=0;i<len1;i++){
if(type==0){
if((d1[i]==d2[i])&&(d1[i]>='A'&&d1[i]<='G')){
date=d1[i]-'A'+1;
type=1;
}
}else if(type==1){
if(d1[i]==d2[i]){
if(d1[i]>='0'&&d1[i]<='9'){
hour=d1[i]-'0';
break;
}else if(d1[i]>='A'&&d1[i]<='N'){
hour=d1[i]-'A'+10;
break;
}
}
}
}
for(int i=0;i<len2;i++){
if((m1[i]>='a'&&m1[i]<='z')||(m1[i]>='A'&&m1[i]<='Z')){
if(m1[i]==m2[i]){
minute=i;
break;
}
}
}
switch(date){
case 1:
cout<<"MON ";
break;
case 2:
cout<<"TUE ";
break;
case 3:
cout<<"WED ";
break;
case 4:
cout<<"THU ";
break;
case 5:
cout<<"FRI ";
break;
case 6:
cout<<"SAT ";
break;
case 7:
cout<<"SUN ";
break;
}
if(hour<10){
cout<<"0";
}
cout<<hour<<":";
if(minute<10){
cout<<"0";
}
cout<<minute<<endl;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/hsmath/pat-advanced.git
git@gitee.com:hsmath/pat-advanced.git
hsmath
pat-advanced
PAT advanced
master

搜索帮助