• 【HDOJ6308】Time Zone(模拟)


    题意:

    以"UTC+X'', "UTC-X'', "UTC+X.Y'', or "UTC-X.Y'' 四种格式给定当地时间,要求转换为北京时间

    思路:Gold_7写的

    我自己转C后字符串处理的模拟题并不熟练啊

     1 #include <cstdio>
     2 #include <cstring>
     3 #include <string>
     4 #include <cmath>
     5 #include <iostream>
     6 #include <algorithm>
     7 #include <map>
     8 #include <set>
     9 #include <queue>
    10 #include <vector>
    11 using namespace std;
    12 typedef long long ll;
    13 typedef unsigned int uint;
    14 typedef unsigned long long ull;
    15 typedef pair<int, int> PII;
    16 typedef vector<int> VI;
    17 #define fi first
    18 #define se second
    19 #define MP make_pair
    20 
    21 int read()
    22 {
    23     int v = 0, f = 1;
    24     char c = getchar();
    25     while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();}
    26     while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar();
    27     return v * f;
    28 }
    29 
    30 char ch[1000];
    31 
    32 int main()
    33 {
    34     int cas = read();
    35     while (cas--)
    36     {
    37         int x = read(), y = read();
    38         scanf("%s", ch);
    39         int flag=1;
    40         int p = 0, q = 0;
    41         if (ch[3]=='-')flag=-1;
    42         p = p * 10 + ch[4] - '0';
    43         if (ch[5])
    44         {
    45             if (ch[5] != '.')
    46             {
    47                 p = p * 10 + ch[5] - '0';
    48                 if (ch[6] == '.')
    49                     q = ch[7] - '0';
    50             } else
    51             {
    52                 q = ch[6] -'0';
    53             }
    54         }
    55         p*=flag;q*=flag;
    56         p -= 8;
    57         x += p;
    58         y += q * 6;
    59         x += y / 60;
    60         y %= 60;
    61         if (y<0){x--;y+=60;}
    62         x = (x % 24 + 24) % 24;
    63         printf("%02d:%02d
    ", x, y);
    64         for (int i = 0; ch[i]; i++)
    65             ch[i] = 0;
    66     }
    67 }
  • 相关阅读:
    Windows环境下OpenLDAP安装配置
    jobcenter在Windows下连携LDAP
    OpenLDAP搭建
    Go 函数 #3
    Go 数组/多维数组/切片/map #2
    Go内置类型/变量/常量 #1
    git常用命令
    makefile基础_1
    kubernete的service
    配置开发环境
  • 原文地址:https://www.cnblogs.com/myx12345/p/9362529.html
Copyright © 2020-2023  润新知