编程实现输入年份得到生肖属相,用一个方程式完成
某一年对应的一个生肖
那么我们可以定一个叫映射的东西:
y=f(x);
其中x为年份,y为生肖。
12年一个轮回y=f(x+12n);
其中n=1,2,3,4...自然数的集合。
那么就有f(x) = f(x+12n);
这个是个周期函数。
对于周期函数的处理,请用数学演绎法。
在程序里面叫做递归。
over.
losingrose(303864496) 11:32:16
public static class LunarCalendar
{
private static string[] shengxiaoArr = new string[ ] { "鼠", "牛", "虎", "兔", "龙", "蛇", "马", "羊", "猴", "鸡", "狗", "猪" };
public static string GetCNName(int CurYear)
{
int BeginYear = 1908;
int Span = CurYear - BeginYear;
return shengxiaoArr[(Span + 8 + 12000) % 12]; // 加是为了防止出现负数
}
}
ZuneTwo(83210783) 11:32:17
¢関亍愛ぁ(281840041) 11:32:46
㊣云希 (22536973) 11:32:52
已知
{鼠=0,牛=1,......猪=11}
f(2008) = 0;
f(2009) = 1;
ZuneTwo(83210783) 11:33:00
㊣云希 (22536973) 11:33:01
程序里面递归一下。
losingrose(303864496) 11:33:42
我发的那个就是返回生肖的
¢関亍愛ぁ(281840041) 11:34:09
*CC(15276869) 11:34:10
年份 - 12 * Math.Floor(年份 / 12) - 3
Subscribe to:
Post Comments (Atom)
Search This Blog
Labels
news
China
society
Cheng Du
chengdu
live
economy
EARTH
Sichuan
entertainment
health
ET
dnn
medicine
tip
Children
Olympic Games
SOS
Tibet
module
school
ACTIVEX
RMB
Tibet incident
WSS
acupuncture
banting
compare
cure
enterprise forms
herbalist doctor
industry
integration
internet
meaningful
optimizing
question
.net
AIM / AOL
Android 灭鼠
Android 猪
CPPCC
Data delay load
Differencing disks
GoogleTalk
Holidays
ICQ
IM
IT
Interpersonal
MSDN programmer
MSN
NewSID
PLANET
Phishing
QQ
Session
TUS 翻墙 GFW
Traffic
Translation
UFO
VPC
What is the most regret in life
YAHOO
advantage
android
answer
aphorism
blog
born
business
cancer
conclusion
discuss
extraordinary memory
festival
film
fish
fo
fun
help
human
interesting
man
match
microsoft
music
new theory
old
photo
pidgin
plan
power
problem
procreate
relations
say
sharepoint
sid
solve
template
test
version
vs2010
wangboqiang
woman
words
四角号码在线查询
墙 GFW Android
开发 vs2008 vss2005 win2008
No comments:
Post a Comment