YTU 2596: 编程题B-日期格式

2596: 编程题B-日期格式

时间限制: 1 Sec  内存限制: 128 MB
提交: 981  解决: 74

题目描述

注:本题只需要提交编写的函数部分的代码即可。

将输入的日期格式 月/日/年  修改为 年-月-日的格式输出 。请编写缺少的函数output。

#include<stdio.h>
#include <iostream>
using namespace std;
struct date
{
    int year;
    int month;
    int day;
};
int main()
{
    struct date vd;
    void output(struct date da);
    scanf("%d/%d/%d",&vd.month,&vd.day,&vd.year);
    output(vd);
    return 0;
}

输入

月/日/年

输出

年-月-日

样例输入

6/23/2014

样例输出

2014-6-23

迷失在幽谷中的鸟儿,独自飞翔在这偌大的天地间,却不知自己该飞往何方……

#include<stdio.h>
#include <iostream>
using namespace std;
struct date
{
    int year;
    int month;
    int day;
};
int main()
{
    struct date vd;
    void output(struct date da);
    scanf("%d/%d/%d",&vd.month,&vd.day,&vd.year);
    output(vd);
    return 0;
}
void output(struct date da)
{
    printf("%d-%d-%d",da.year,da.month,da.day);
}

posted @ 2016-02-14 23:10  小坏蛋_千千  阅读(336)  评论(0编辑  收藏  举报