zoukankan      html  css  js  c++  java
  • PTA乙级 (1014 福尔摩斯的约会 (20分)、(英文字母转换成数字类型))

    1014 福尔摩斯的约会 (20分)

    https://pintia.cn/problem-sets/994805260223102976/problems/994805308755394560

    英文字母转换成数字类型:

     代码:

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <string>
    #include <cmath>
    #include <algorithm>
    using namespace std;
    int main()
    {
    	int length1,length2,count=0;
    	string str1,str2,str3,str4;
    	cin>>str1>>str2>>str3>>str4;
    	int len1=str1.length();
    	int len2=str2.length();
    	int len3=str3.length();
    	int len4=str4.length();
    	if(len1<len2) length1=len1;else length1=len2;
    	if(len3<len4) length2=len3;else length2=len4;
    	for(int i=0;i<length1;i++)
    	{
    		if((str1[i]==str2[i])&&(str1[i]>='A'&&str1[i]<='G')&&(count==0)) 
    		{
    			count++;
    			if(str1[i]=='A') cout<<"MON ";
    			else if(str1[i]=='B') cout<<"TUE ";
    			else if(str1[i]=='C') cout<<"WED ";
    			else if(str1[i]=='D') cout<<"THU ";
    			else if(str1[i]=='E') cout<<"FRI ";
    			else if(str1[i]=='F') cout<<"SAT ";
    			else if(str1[i]=='G') cout<<"SUN ";
    		}
    		else if((count==1)&&(str1[i]==str2[i])&&((str1[i]>='0'&&str1[i]<='9')||(str1[i]>='A'&&str1[i]<='N')))
    		{
    			count++;
    			if(str1[i]>='0'&&str1[i]<='9') cout<<"0"<<str1[i]<<":";
    			else if(str1[i]>='A'&&str1[i]<='N') cout<<((int)str1[i])-55<<":";
    		}
    		if(count==2) break;
    	}
    	for(int i=0;i<length2;i++)
    	{
    		if((str3[i]==str4[i])&&((str3[i]>='a'&&str3[i]<='z')||(str3[i]>='A'&&str3[i]<='Z')))
    		{
    			if(i>=0&&i<=9) {cout<<"0"<<i; break;}
    			else {cout<<i; break;}
    		}
    	}
    	return 0;
    }
    天晴了,起飞吧
  • 相关阅读:
    Linux压缩和解压类指令
    Linux 搜索查找类指令
    Linux时间日期类指令
    Linux文件目录类指令
    Linux帮助指令
    Linux运行级别
    微信授权获取code/openid
    微信公众配置
    MySQL规范
    PHP7搭建项目遇到的坑
  • 原文地址:https://www.cnblogs.com/jianqiao123/p/12253790.html
Copyright © 2011-2022 走看看