根据我国古代流传的天干、地支、属相都可以表示一个人的生日.据

根据我国古代流传的天干、地支、属相都可以表示一个人的生日.据你的出生年月,可以知道你是哪个星座.我们知道3月21日到4月19日出生的星座是白羊座,4月20日到5月20日出生的是金牛座,假设其他的星座我们不知道.如:你的出生月日是4月12日,则你就属于“白羊座”.试用算法来解决我们提供的部分星座资料的算法.

答案

:算法如下:

第一步,输入生日的月日A(写成“月.日”的形式);

第二步,如果A<3.2显示星座未知;

第三步,否则,若A<4.19则输出“你的星座是:白羊座”;

第四步,否则若A<5.20则输出“你的星座是:金牛座”;

第五步,否则输出“星座未知”.

算法的程序框图如图1-1-26所示:

图1-1-26

思路分析:

本题是一个很新颖的题目,只要将生日与所给数据比较即可,首先将生日规定为先月后日的形式,如果A<3.2显示星座未知;如果3.2<A<4.19则星座是白羊座;如果4.19<A<5.20则星座是金牛座;如果A≥5.20也显示星座未知.

相关题目

绿色消费是以保护消费者健康和节约资源为主旨,符合人的
绿色消费是以保护消费者健康和节约资源为主旨,符合人的健康和环境保护标准的各种消费行为的总称,核心是(     ) A.适度消费 B.可持续性消费
下面语段中画线的三个句子存在语病,请改正。     前年1
下面语段中画线的三个句子存在语病,请改正。     前年1月12日,国务院批准了《皖江城市带承接产业转移示范区规划》,确定芜湖为示范区核心城市
People often said Thomas Edison was the greatest genius of his age.There are
People often said Thomas Edison was the greatest genius of his age.There are only a few men in all of history,who have changed the lives of other men as much as the inventor of the first useful
下列句子中加点成语使用恰当的一项是( )   A.学校团委
下列句子中加点成语使用恰当的一项是( )   A.学校团委组织志愿者利用暑期为孤寡老人义务服务,同学们纷纷响应,争先恐后地报名参加了。   B
读图,完成下列要求。(10分) (1)图中字母代表的气压带
读图,完成下列要求。(10分) (1)图中字母代表的气压带为:     A                B                 C                D 
Richard looked at the envelope and      Jenny's handwriting immediately. A
Richard looked at the envelope and      Jenny's handwriting immediately. A. recognized         B. found                C. realized         D. concerned
Not ____with the quality of your goods, I will certainly not advise others to b
Not ____with the quality of your goods, I will certainly not advise others to buy them.        A.being impressed     B.impressing     C.impressed      D.having impressed
 -----Oh, Tom, what did you do this summer vacation? -----Guess what? I had _
 -----Oh, Tom, what did you do this summer vacation? -----Guess what? I had _____ great fun in _______ show performance “the voice of China”. A. a, the  B the, the C. /,a      D./, the

最新题目