时间格式转换

#include <stdio.h>


int main()
{
    int a, b, x, y;
    scanf("%d:%d", &a, &b);
    if(a == 0)
    {
        x = 12;
        y = b;
        printf("%02d:%02d AM\n", x, y);
    }
    else if((a > 0)&&(a < 12))
    {
        x = a;
        y = b;
        printf("%d:%02d AM\n", x, y);
    }
    else if(a == 12)
    {
        x = a;
        y = b;
        printf("%d:%02d PM\n", x, y);
    }
    else if((a > 12)&&(a < 24))
    {
        x = a - 12;
        y = b;
        printf("%d:%02d PM\n", x, y);
    }
    return 0;
}

相关文章:

  • 2021-11-27
  • 2021-11-27
  • 2021-11-27
  • 2021-11-12
  • 2021-11-12
  • 2021-11-12
  • 2021-11-12
  • 2021-11-18
猜你喜欢
  • 2021-12-08
  • 2021-11-28
  • 2021-11-03
  • 2021-09-17
  • 2021-08-04
相关资源
相似解决方案