PAT:1061. Dating (20) AC

本文介绍了一个使用C语言实现的程序,该程序能够解析输入的字符串形式的日期和时间,并将其转换为具体的一周中的某一天及具体的时间点。通过比较两组输入字符串中的相同部分,程序能够确定出共同的日期和时间。
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<algorithm>
using namespace std;

char alp[7][5]={"MON","TUE","WED","THU","FRI","SAT","SUN"};

int main()
{
  /*char test='E';
  printf("%d:",test-'A'+10);*/
  char s[4][70];
  int len[4];
  for(int i=0 ; i<4 ; ++i)
  {
    scanf("%s",s[i]);
    len[i]=strlen(s[i]);
  }
  int index=0,minlen=min(len[0],len[1]);
  for(index=0 ; index<minlen ; ++index)          //星期
  {
    if(s[0][index]==s[1][index] && s[0][index]>='A' && s[0][index]<='G')
    {
      printf("%s ",alp[s[0][index]-'A']);
      break;
    }
  }

  for(++index ; index<minlen ; ++index)          //时//【warning】必须先++index,不然还是指向D,下面出现错误
  {
    if(s[0][index]==s[1][index])
    {
      if(s[0][index]>='A' && s[0][index]<='N')
      {
        printf("%02d:",s[0][index]-'A'+10);      //【warning】看清格式!
        break;
      }
      else if(s[0][index]>='0' && s[0][index]<='9')
      {
        printf("%02d:",s[0][index]-'0');      //【warning】转为数字,才能02d输出
        break;
      }
    }
  }
  minlen=min(len[2],len[3]);
  for(int i=0 ; i<minlen ; ++i)              //分
  {
    if(s[2][i]==s[3][i] && isalpha(s[2][i]))
    {
      printf("%02d\n",i);
      break;
    }
  }
  return 0;
}

转载于:https://www.cnblogs.com/Evence/p/4325561.html

using UnityEngine; using System.Collections; using UnityEngine.UI; using ConsoleTestWindows; using XLua; namespace LuaFramework { /// <summary> /// </summary> [LuaCallCSharp] public class Main : MonoBehaviour { private ConsoleWindow consoleWin; //public string ResUrl; public string WebUrl; public string AgentID; public string UIVersion; public int GameCode; public bool updateMode; void Start() { AppConst.GameCode = GameCode; #if UNITY_EDITOR AppConst.UpdateMode = updateMode; AppConst.UIVersion = UIVersion; AppConst.WebUrl = WebUrl; AppConst.AgentID = AgentID; consoleWin = new ConsoleWindow(); consoleWin.Initialize(); consoleWin.SetTitle("Lua_Dating"); #endif //Debug.LogError("Main Start**********************************"); //System.Console.OutputEncoding = System.Text.Encoding.Default; AppFacade.Instance.StartUp(); //启动游戏 } public static void consoleprint(string str, int color) { switch(color) { case 1: System.Console.ForegroundColor = System.ConsoleColor.Black; break; case 2: System.Console.ForegroundColor = System.ConsoleColor.DarkBlue; break; case 3: System.Console.ForegroundColor = System.ConsoleColor.DarkGreen; break; case 4: System.Console.ForegroundColor = System.ConsoleColor.DarkCyan; break; case 5: System.Console.ForegroundColor = System.ConsoleColor.DarkRed; break; case 6: System.Console.ForegroundColor = System.ConsoleColor.DarkMagenta; break; case 7: System.Console.ForegroundColor = System.ConsoleColor.DarkYellow; break; case 8: System.Console.ForegroundColor = System.ConsoleColor.Gray; break; case 9: System.Console.ForegroundColor = System.ConsoleColor.DarkGray; break; case 10: System.Console.ForegroundColor = System.ConsoleColor.Blue; break; case 11: System.Console.ForegroundColor = System.ConsoleColor.Green; break; case 12: System.Console.ForegroundColor = System.ConsoleColor.Cyan; break; case 13: System.Console.ForegroundColor = System.ConsoleColor.Red; break; case 14: System.Console.ForegroundColor = System.ConsoleColor.Magenta; break; case 15: System.Console.ForegroundColor = System.ConsoleColor.Yellow; break; default: System.Console.ForegroundColor = System.ConsoleColor.White; break; } System.Console.WriteLine(str); } private void OnDestroy() { #if UNITY_EDITOR consoleWin.Shutdown(); #endif } } }
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值