#6789: 為何過不了,請協助


macosx19961220 (eric)

學校 : 國立嘉義高級中學
編號 : 26314
來源 : [140.114.216.89]
最後登入時間 :
2017-10-11 00:50:50
a003. 兩光法師占卜術 | From: [24.4.41.22] | 發表日期 : 2012-07-14 12:27

#include<iostream>

#include<cstdlib>

 

using namespace std;

int main()

{

    int M , D, S;

    cout<<"please input your month and date";

    cin>>M, cin>>D;

    S=(M*2+D)%3 ;

    

    if (S==0)

        cout<<"普通";

    else if(S==1)

        cout<<"";

    else

        cout<<"大吉";

    return 0;


 
#6790: Re:為何過不了,請協助


passerr (20130326 0340 48)

學校 : 不指定學校
編號 : 8516
來源 : [125.224.93.117]
最後登入時間 :
2024-09-05 12:09:52
a003. 兩光法師占卜術 | From: [114.41.44.9] | 發表日期 : 2012-07-14 19:09

#include

#include

 

using namespace std;

int main()

{

    int M , D, S;

    cout<<"please input your month and date";

    cin>>M, cin>>D;

    S=(M*2+D)%3 ;

    

    if (S==0)

        cout<<"普通";

    else if(S==1)

        cout<<"";

    else

        cout<<"大吉";

    return 0;


我想大概是不需要這行cout<<"please input your month and date";

因為有很多輸入,所以用while(cin>>M>>D),請參考a001: 哈囉

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
    int M,D,S;
    //cout<<"please input your month and date";
    //cin>>M, cin>>D;
while(cin>>M>>D)
{
    S=(M*2+D)%3;
    if (S==0)
        cout<<"普通";
    else if(S==1)
        cout<<"吉";
    else
        cout<<"大吉";
}
    return 0;
}
你已經很接近答案了,再試試看吧!

 
ZeroJudge Forum