#3260: 安怎都是平年 =口=


lmk999999 (lmk999999)


我怎麼打都是平年呀!><

誰可以幫我一下... T T

 #include<iostream>

#include<math.h> 

 

using namespace std;

 

int main(int argc, char *argv[])

      {

          int x,a,b,c ;

          float m;

          while(cin >> x)

          {

                    

                    if (x/4==a)

                    {

                        if (x/100==b)

                        {

                            cout << "平年" << endl ;

                        }

                        else

                        {

                            cout << "閏年" << endl ;

                        }

                    }

                    else if (x/400==c)

                    {

                        cout << "閏年" << endl ;

                    } 

                    else

                    {

                        cout << "平年" << endl ;

                    }

          }

          return 0;}

 

 

 

 

#3262: Re:安怎都是平年 =口=


example (學姊)


我怎麼打都是平年呀!><

誰可以幫我一下... T T

 #include

#include 

using namespace std;

int main(int argc, char *argv[]) {

          int x,a,b,c ;

          float m;

          while(cin >> x) {

                    if (x/4==a) {

                        if (x/100==b) {

                            cout << "平年" << endl ;

                        } else {

                            cout << "閏年" << endl ;

                        }

                    } else if (x/400==c) {

                        cout << "閏年" << endl ;

                    }  else {

                        cout << "平年" << endl ;

                    }

          }

          return 0;

}

 

 a, b, c 沒有初始化喔

 如果要判斷餘數的話請用 % 運算子

#3269: Re:安怎都是平年 =口=


b821213 (後繼無人)


我怎麼打都是平年呀!><

誰可以幫我一下... T T

 #include

#include 

using namespace std;

int main(int argc, char *argv[]) {

          int x,a,b,c ;

          float m;

          while(cin >> x) {

                    if (x/4==a) {

                        if (x/100==b) {

                            cout << "平年" << endl ;

                        } else {

                            cout << "閏年" << endl ;

                        }

                    } else if (x/400==c) {

                        cout << "閏年" << endl ;

                    }  else {

                        cout << "平年" << endl ;

                    }

          }

          return 0;

}

 

 a, b, c 沒有初始化喔

 如果要判斷餘數的話請用 % 運算子

我個人看完你的程式倒是覺得...你似乎對C有很大的誤解@@

建議你還是先回去把課本(一般來說都是Deitel那本)前幾個章節看仔細

看完再來解

有些地方很明顯地表示你連基本的運算操作都不太熟析喔...