#420: 請救救我 我跑不出來


eszerfrm (朱小弟)


幫我看看哪裡錯了

#include"iostream"

using namespace std;
int main() {
    int M,D,S;
    while(cin >> M >> D)
     S = (M * 2 + D)%3;
    if (S == 2)
     cout << "大吉" <<endl;
             
    if (S == 1)
     cout <<  "吉" <<endl;
     
    else 
     cout << "普通" <<endl;
    
     {
          return 0;
          }
}

#421: Re:請救救我 我跑不出來


POOHccc ()


幫我看看哪裡錯了

#include"iostream"

using namespace std;
int main() {
    int M,D,S;
    while(cin >> M >> D)
     S = (M * 2 + D)%3;
    if (S == 2)
     cout << "大吉" <<endl;
             
    if (S == 1)
     cout <<  "吉" <<endl;
     
    else 
     cout << "普通" <<endl;
    
     {
          return 0;
          }
}

 

紅色地方是我幫你補充的

1. 大括號部分是因為case不止一組,若不加的話,while只會到S = (M * 2 + D)%3;就結束了

2. 加else是因為,若不加else的話,當S是2的時候,會輸出大吉、普通,這就答案就錯誤了

 

#include"iostream"

using namespace std;
int main() {
    int M,D,S;
    while(cin >> M >> D){
     S = (M * 2 + D)%3;
    if (S == 2)
     cout << "大吉" <<endl;
            
    else if (S == 1)
     cout <<  "吉" <<endl;
    
    else
     cout << "普通" <<endl;
    }
     {
          return 0;
          }
}

#422: Re:請救救我 我跑不出來


eszerfrm (朱小弟)


幫我看看哪裡錯了

#include"iostream"

using namespace std;int main() {    int M,D,S;    while(cin >> M >> D)     S = (M * 2 + D)%3;     if (S == 2)      cout << "大吉" <<endl;                   if (S == 1)      cout <<  "吉" <<endl;          else       cout << "普通" <<endl;           {          return 0;           } } 

 

紅色地方是我幫你補充的

1. 大括號部分是因為case不止一組,若不加的話,while只會到S = (M * 2 + D)%3;就結束了

2. 加else是因為,若不加else的話,當S是2的時候,會輸出大吉、普通,這就答案就錯誤了

 

#include"iostream"using namespace std;int main() {    int M,D,S;    while(cin >> M >> D){     S = (M * 2 + D)%3;    if (S == 2)     cout << "大吉" <<endl;                 else if (S == 1)     cout <<  "吉" <<endl;         else      cout << "普通" <<endl;    }     {          return 0;          }} 


謝啦...我懂了
#771: Re:請救救我 我跑不出來


shane0000028 (賢賢易色)


幫我看看哪裡錯了

#include <iostream>  
using namespace std;  
int main()  
{  
    int M,D,S;  
    while(cin >> M >> D)  
    {  
        S = (M * 2 + D) % 3;  
        if(S==2)  
            cout << "大吉" << endl;  
        else if(S==1)  
            cout << "吉" << endl;  
        else 
            cout << "普通" << endl;  
    } 
    return 0;
}