首页
社区
课程
招聘
[原创]史上最全的程序猿春节倒计时
发表于: 2014-1-16 08:51 7105

[原创]史上最全的程序猿春节倒计时

2014-1-16 08:51
7105
VB版
MsgBox ("春节倒计时:" & DateDiff("d", Date, "2014-01-31") & "天")

sql版
print N'春节倒计时:' + convert(nvarchar(50), DateDiff(day,getdate(),'2014-01-31')) + N'天'

Perl版  作者:baccon
#!/usr/bin/perl -w

sub  callme{
  my $time=time();
  my ($a,$b,$c,$d)=localtime($time);
  printf  "New year :%dday(s)".(' 'x2)."%dhours".(' 'x2)."%dseconds\n",31-$d,24-$c,60-$b;
}
&callme;

C版 作者:gemo
#include <stdio.h>
#include <time.h>
int main () {
    time_t now = time(NULL);
    struct tm newyear = *localtime(&now);
    int seconds;
    newyear.tm_hour = 0;
    newyear.tm_min = 0;
    newyear.tm_sec = 0;
    newyear.tm_mon = 0;
    newyear.tm_mday = 31;
    seconds = (int)difftime(mktime(&newyear), now);
    printf("春节倒计时:%d天\n", (seconds / (3600*24)));
    return 0;
}

C++版  作者:gemo
#include <iostream>
#include <chrono>
#include <ctime>
using namespace std::chrono;

time_point<system_clock> get_target_date(int year, int month, int day) {
    tm t;
    memset(&t, 0, sizeof(tm));
    t.tm_year = year - 1900;
    t.tm_mon = month - 1;
    t.tm_mday = day;
    return system_clock::from_time_t(mktime(&t));
}
int main() {
    time_point<system_clock> start = system_clock::now();
    time_point<system_clock> end = get_target_date(2014, 1, 31);
    seconds sub_secs = (duration_cast<seconds>)(end - start);
    std::cout<<"春节倒计时:"<< (sub_secs.count() / (3600*24))<<"天"<<std::endl;
    return 0;
}

lua版  作者:gemo
d = os.time{year=2014,month=1,day=31,hour=0,min=0,sec=0}
print(string.format("春节倒计时:%d天", (d-os.time())/(3600*24)))

linux shell脚本 作者:LeavesBNW
#!/bin/sh
year=`date --date="2014-1-31 00:00:00"  "+%s"`
while [ 0 ]
do
current=`date "+%s"`
diff=$(($year-$current))
echo -n "倒计时   "
echo `date --date="@$diff"  "+%d%t%H:%M:%S"`
sleep 1
clear
done

delphi版  作者:谷月轩
showmessage(IntToStr(DaysBetween(Now,StrToDateTime('2014-2-1 上午 12:00:00'))));

Excel版  作者:playboysen
=DATEVALUE("2014-1-31")-TODAY()

Python 2.X  作者:playboysen
>>> from datetime import date,timedelta
>>> print u"春节倒计时:%d天!" % (date(2014,1,31)-date.today()).days
春节倒计时:15天!

易语言版  作者:mms
标准输出 (, “春节倒计时:” + 到文本 (30 - 到数值 (取日 (取现行时间 ()))) + “天”)

bat版  作者:xJJuno
@echo off
set date1=%date:~0,10%
set date2=2014-1-31
echo WScript.Echo DatePart("y", "%date2%")-DatePart("y", "%date1%")>%temp%\t.vbs
for /f %%i in ('cscript //nologo %temp%\t.vbs') do (echo 春节倒计时:%%i天)
pause

骆驼版  作者:licthday
刚研究了一下草泥马语言,由于此语言太过奇葩,只能使用数字计算和输入输出,所以以下代码只能直接输出

代码:
   草        草
   草        马
草草草泥泥草草泥泥
草              草
草      ━      泥
草  ┳┛ ┗┳  草
泥  ┃      ┃  草
泥              马
草      ┻      马
草              泥     马             草草草草草             泥
草草草      草草泥      草 泥       草          草       草 草
    草      泥           草  马   草             马    草  泥
    马      草            草   草草草泥草泥草草草草草草   草
    泥      草             草                           泥
    草      马              草                         马
    草      泥               马                       草
    草      草                草                    草
    泥      草                 草草泥草泥泥泥草泥草草
    草      草泥马草马草泥马草草草草草泥泥草草泥草泥泥泥泥泥草泥泥草
    马                                                            草
    马                                                            草泥马草草草
    草                                                            草         泥
    泥                                                            泥           草
    泥                                                            草            马
    草                                                            马
    草泥马草草草草草泥草草草草草马草马草泥马草草草草草泥泥泥泥马草马
    草泥马                           草泥草
    草草泥                           草草草
    草草马                           草马草
泥马草草草草草泥草泥泥草草泥草草泥草泥草草泥马草马草泥马草草草马马河蟹
输出结果为 春节倒计时: 15 天

********************************************************
修改了一下排版,祝大家马上有钱,哈哈哈哈

大家继续.~我来更新.~还有脚本啥的,乱七八糟的,都上来吧.

[培训]《安卓高级研修班(网课)》月薪三万计划,掌握调试、分析还原ollvm、vmp的方法,定制art虚拟机自动化脱壳的方法

收藏
免费 0
支持
分享
最新回复 (30)
雪    币: 261
活跃值: (55)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
2
草泥玛版这个版到底是啥样的..?
2014-1-16 08:56
0
雪    币: 223
活跃值: (516)
能力值: ( LV13,RANK:520 )
在线值:
发帖
回帖
粉丝
3
我也不知道.但是好多地方听别人说有这种语言.百度上好像也有看到过.
2014-1-16 09:02
0
雪    币: 218
能力值: (RANK:10 )
在线值:
发帖
回帖
粉丝
4
草泥马版,太神奇了,呵呵向楼主的老师们学习了
2014-1-16 09:10
0
雪    币: 223
活跃值: (516)
能力值: ( LV13,RANK:520 )
在线值:
发帖
回帖
粉丝
5


上传的附件:
2014-1-16 09:15
0
雪    币: 55
活跃值: (519)
能力值: ( LV6,RANK:80 )
在线值:
发帖
回帖
粉丝
6
[QUOTE=半斤八兩;1255583]

[/QUOTE]

这是一门无法直视的语言,还有调试器gmhd
2014-1-16 09:27
0
雪    币: 1839
活跃值: (295)
能力值: ( LV9,RANK:370 )
在线值:
发帖
回帖
粉丝
7
什么节奏??
2014-1-16 09:28
0
雪    币: 244
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
草泥马 真名叫 羊驼
2014-1-16 09:52
0
雪    币: 236
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
9
https://code.google.com/p/grass-mud-horse/
草泥马语
2014-1-16 10:02
0
雪    币: 257
活跃值: (44)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
10
都没人么,我来
2014-1-16 11:47
0
雪    币: 257
活跃值: (44)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
11
c语言版

#include <stdio.h>
#include <time.h>
int main () {
    time_t now = time(NULL);
    struct tm newyear = *localtime(&now);
    int seconds;
    newyear.tm_hour = 0;
    newyear.tm_min = 0;
    newyear.tm_sec = 0;
    newyear.tm_mon = 0;
    newyear.tm_mday = 31;
    seconds = (int)difftime(mktime(&newyear), now);
    printf("春节倒计时:%d天\n", (seconds / (3600*24)));
    return 0;
}
2014-1-16 11:49
0
雪    币: 257
活跃值: (44)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
12
c++版(c++11 only)

#include <iostream>
#include <chrono>
#include <ctime>
using namespace std::chrono;

time_point<system_clock> get_target_date(int year, int month, int day) {
    tm t;
    memset(&t, 0, sizeof(tm));
    t.tm_year = year - 1900;
    t.tm_mon = month - 1;
    t.tm_mday = day;
    return system_clock::from_time_t(mktime(&t));
}
int main() {
    time_point<system_clock> start = system_clock::now();
    time_point<system_clock> end = get_target_date(2014, 1, 31);
    seconds sub_secs = (duration_cast<seconds>)(end - start);
    std::cout<<"春节倒计时:"<< (sub_secs.count() / (3600*24))<<"天"<<std::endl;
    return 0;
}
2014-1-16 11:50
0
雪    币: 257
活跃值: (44)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
13
lua版

d = os.time{year=2014,month=1,day=31,hour=0,min=0,sec=0}
print(string.format("春节倒计时:%d天", (d-os.time())/(3600*24)))
2014-1-16 11:51
0
雪    币: 29
活跃值: (40)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
14
linux shell脚本:

#!/bin/sh
year=`date --date="2014-1-31 00:00:00" "+%s"`
while [ 0 ]
do
current=`date "+%s"`
diff=$(($year-$current))
echo -n "倒计时 "
echo `date --date="@$diff" "+%d%t%H:%M:%S"`
sleep 1
clear
done
2014-1-16 12:11
0
雪    币: 102
活跃值: (31)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
15
delphi版
showmessage(IntToStr(DaysBetween(Now,StrToDateTime('2014-2-1 上午 12:00:00'))));
2014-1-16 12:17
0
雪    币: 590
活跃值: (177)
能力值: ( LV9,RANK:680 )
在线值:
发帖
回帖
粉丝
16
Excel版
=DATEVALUE("2014-1-31")-TODAY()

Python 2.X
>>> from datetime import date,timedelta
>>> print u"春节倒计时:%d天!" % (date(2014,1,31)-date.today()).days
春节倒计时:15天!
2014-1-16 13:08
0
雪    币: 1344
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
mms
17
好吧,易语言

标准输出 (, “春节倒计时:” + 到文本 (30 - 到数值 (取日 (取现行时间 ()))) + “天”)
2014-1-16 13:09
0
雪    币: 12921
活跃值: (4026)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
18
脚本版
@echo off
set date1=%date:~0,10%
set date2=2014-1-31
echo WScript.Echo DatePart("y", "%date2%")-DatePart("y", "%date1%")>%temp%\t.vbs
for /f %%i in ('cscript //nologo %temp%\t.vbs') do (echo 春节倒计时:%%i天)
pause
2014-1-16 16:30
0
雪    币: 66
活跃值: (183)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
19
刚研究了一下草泥马语言,由于此语言太过奇葩,只能使用数字计算和输入输出,所以以下代码只能直接输出

   草        草
   草        马
草草草泥泥草草泥泥
草              草
草      ━      泥
草  ┳┛ ┗┳  草
泥  ┃      ┃  草
泥              马
草      ┻      马
草              泥     马             草草草草草             泥
草草草      草草泥      草 泥       草          草       草 草
    草      泥           草  马   草             马    草  泥
    马      草            草   草草草泥草泥草草草草草草   草
    泥      草             草                           泥
    草      马              草                         马
    草      泥               马                       草
    草      草                草                    草
    泥      草                 草草泥草泥泥泥草泥草草
    草      草泥马草马草泥马草草草草草泥泥草草泥草泥泥泥泥泥草泥泥草
    马                                                            草
    马                                                            草泥马草草草
    草                                                            草         泥
    泥                                                            泥           草
    泥                                                            草            马
    草                                                            马
    草泥马草草草草草泥草草草草草马草马草泥马草草草草草泥泥泥泥马草马
    草泥马                           草泥草
    草草泥                           草草草
    草草马                           草马草
泥马草草草草草泥草泥泥草草泥草草泥草泥草草泥马草马草泥马草草草马马河蟹
输出结果为 春节倒计时: 15 天

********************************************************
修改了一下排版,祝大家马上有钱,哈哈哈哈
2014-1-16 18:18
0
雪    币: 223
活跃值: (516)
能力值: ( LV13,RANK:520 )
在线值:
发帖
回帖
粉丝
20

居然真写出来了,厉害.
2014-1-16 22:05
0
雪    币: 3343
活跃值: (1243)
能力值: ( LV4,RANK:40 )
在线值:
发帖
回帖
粉丝
21
我表示我是来看草泥马语言的--
2014-1-16 23:12
0
雪    币: 59
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
22
楼主淡腾很啊
2014-1-16 23:44
0
雪    币: 188
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
23
那个草泥马语言太牛逼了。呵呵
2014-1-17 09:42
0
雪    币: 237
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
24
,确实好丰富的说,这个帖子很强大.哈哈哈
2014-1-17 10:34
0
雪    币: 14983
活跃值: (5285)
能力值: ( LV15,RANK:880 )
在线值:
发帖
回帖
粉丝
25
那个骆驼版的最好看~
2014-1-17 10:54
0
游客
登录 | 注册 方可回帖
返回
//