PAT 1014 福尔摩斯的约会

#include <iostream>
#include <cstring>
#include <sstream>


using namespace std;



void DAY(string res[])
{
	if(res[0]=="A")
	{
		res[0] = "MON";
	}
	if(res[0]=="B")
	{
		res[0] = "TUE";
	}
	if(res[0]=="C")
	{
		res[0] = "WED";
	}
	if(res[0]=="D")
	{
		res[0] = "THU";
	}
	if(res[0]=="E")
	{
		res[0] = "FRI";
	}
	if(res[0]=="F")
	{
		res[0] = "SAT";
	}
	if(res[0]=="G")
	{
		res[0] = "SUN";
	}
	
}

void HOUR(string res[])
{     
      char h;
      string x = res[1];
      for(int i=0;i<x.length();i++)
      {
      	h = x[i];
	  }
	  
	  if(h-'0'<10)
	  {
	  	 x='0'+x;
	  	 res[1] = x;
	  }
	  else{
	  	
		  int hour = h-'0'-7;
		  
		  std::stringstream ss;
		  std::string str;
		  ss<<hour;
		  ss>>str;
		  res[1] = str;
		  
	  }
	  
}

int main()
{
  
  string res[10];	
  int cc = 0;

  string s[10000];
  int k=0;
  int f=0;
  
  while(k<4)
  {
  	cin>>s[f++];
  	k++;
  }

    string fir_s = s[0];
    string sec_s = s[1];
    
    int len1 = fir_s.length();
    int len2 = sec_s.length();
    int len_t = 0;
    
    int flag_1 = 0;
    
    if(len1>=len2)
    {
    	len_t = len2;
	}
    else{
    	len_t = len1;
	}
    
    for(int i=0;i<len_t;i++)
        {
    	    if(flag_1 == 0)
    	    {
    	    	if(fir_s[i] == sec_s[i] && fir_s[i]-'0'>=17 && fir_s[i]-'0'<=30)
    	    	{
    	    		//cout<<"字母均为大写"<<fir_s[i]<<" "<<sec_s[i]<<endl; 
    	    		res[cc] = fir_s[i]; cc++;
    	    	    i++; 
    	    		flag_1 = 1; 
				}
			}
			if(flag_1 == 1)
			{
				if(fir_s[i] == sec_s[i] && fir_s[i]-'0'>=0 && fir_s[i]-'0'<=30)
    	    	{
    	    		//cout<<"字母均为大写 可以有数字"<<fir_s[i]<<" "<<sec_s[i]<<endl; 
    	    		res[cc] = fir_s[i]; cc++;
    	    		flag_1 = 2; 
				}
			}
	    }
	    
    
   string thi_s = s[2];
   string for_s = s[3];
   
   int len_n=0;
   int len_3 = thi_s.length();
   int len_4 = for_s.length();
  
   if(len_3>=len_4)
   {
   	   len_n = len_4;
   } 
	else{
		len_n = len_3;
	}
   
   for(int i=0;i<len_n;i++)
   {    
        int num = thi_s[i]-'0';
   	    if(thi_s[i] == for_s[i] && num>=17 && num<=42 || thi_s[i]==for_s[i] && num>=49 && num<=74)
   	    {
   	    	std::stringstream ss;
		    std::string str;
		   
		    ss<<i;
		    ss>>str;
		    
			if(i<10)
		    {
		       str = "0"+str;
			}
			
   	        res[cc] = str; cc++;
   	        break;
		}
   }
   
   
   DAY(res);
   HOUR(res);
   cout<<res[0]<<" "<<res[1]<<":"<<res[2];
   
   
   
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值