Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

很短的AC代碼(相信可以去除struct令到更短)

Posted by miklcct at 2011-06-12 21:07:56 on Problem 3751
#include <cstdio>

using namespace std;

struct Date {
    int Y, M, D, h, m, s;
    bool read() {
        return scanf("%d/%d/%d-%d:%d:%d\n", &Y, &M, &D, &h, &m, &s) == 6;
    }
    void write() {
        printf("%02d/%02d/%02d-%02d:%02d:%02d%s\n", M, D, Y, (h + 11) % 12 + 1, m, s, h < 12 ? "am" : "pm");
    }
};

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        Date date;
        date.read();
        date.write();
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator