占星术程序c++

Astrology Program for C++

本文关键字:c++ 程序 占星术      更新时间:2023-10-16

基本上家庭作业的问题是做一个占星术程序。然后还有一个部分让我感到困惑:"然后增强你的程序,这样如果生日离相邻的星座只有一两天的距离,程序就会宣布生日在一个‘尖峰’上,并输出与该星座相邻的星座运程。"这个程序将有一个很长的多路分支。为每个星座画一个星座运势。"

这是我目前为止写的:

#include <iostream>
using namespace std;
int main()
{
    int month, day;
    char ans, space; 
      do
    {
        cout << "Please Enter the Month of your Birthday Follow by the Day(ex. 12/01): n";
        cin >> month >> space >> day ; 
        if((month == 3 && day >= 21)||(month==4 && day <= 19))
           {
              cout << "You Are an Aries! n";
           }
        else if((month == 4 && day >= 20)||(month==4 && day <= 20))
           {
              cout << "You Are an Taurus! n";
           }
        else if((month == 5 && day >= 21)||(month==6 && day <= 21))
           {
              cout << "You Are an Gemini! n";
           }
        else if((month == 6 && day >= 22)||(month==7 && day <= 22))
           {
              cout << "You Are an Cancer! n";
           }
        else if((month == 7&& day >= 23)||(month==8 && day <= 22))
           {
              cout << "You Are an Leo! n";
           }
        else if((month == 8&& day >= 23)||(month==9 && day <= 22))
           {
              cout << "You Are an Virgo! n";
           }
        else if((month == 9&& day >= 23)||(month==10 && day <= 22))
           {
              cout << "You Are an Libra! n";
           }
        else if((month == 10&& day >= 23)||(month==11 && day <= 21))
           {
              cout << "You Are an Scorpio! n";
           }
        else if((month == 11&& day >= 22)||(month==12 && day <= 21))
           {
              cout << "You Are an Saggitarius! n";
           }
        else if((month == 12&& day >= 22)||(month==1 && day <= 19))
           {
              cout << "You Are an Capricorn! n";
           }
        else if((month == 1&& day >= 20)||(month==2 && day <= 18))
           {
              cout << "You Are an Aquarius! n";
           }
        else if((month == 2&& day >= 19)||(month==3 && day <= 20))
           {
              cout << "You Are an Pisces! n";
           }
        cout << "Would You life to Find Another Horoscope? (Please Type y or Y)n ";
        cin >> ans;
    } while(ans == 'y' || ans == 'Y');
     cout << " Good Bye!n";   
     system("PAUSE");
     return 0;
}

坦率地说,问题中你不理解的部分与编程无关,因此你需要稍微深入了解一下占星术方面的细节。

看看这些链接,看看你是否能理解这个问题。

http://en.wikipedia.org/wiki/Cusp_%28astrology%29

它基本上增加了一个简单的条件,如果出生日期在两个太阳星座之间,它位于一个尖端,你也需要解决这个条件。

,完成。我觉得你需要自己编码。这样你就会学到东西。在SO上发帖之前,也试着谷歌一下。这是一个很好的学习方式。

希望有帮助。