你應該是先做輸入的動作,然後才在做運算。
而且你的變數S之後必未隨著M,D變動。
以下是我依據你的程式而修正的程式碼:
#include<iostream>
#include<cstdlib>
#include<math.h>//基本運算可以不用引入math.h
using namespace std;
int main(int argc,char *argv[])
{
int M,D,S;
while(cin>>M,cin>>D)
{
S=((M*2+D)%3);
if (S==0)
{
cout << "普通"<< endl;
}
else if (S==1)
{
cout << "吉"<< endl;
}
else if (S==2)
{
cout << "大吉"<< endl;
}
}
system("PAUSE");//上傳記得抹掉
return 0;
}
你應該是先做輸入的動作,然後才在做運算。
而且你的變數S之後必未隨著M,D變動。
以下是我依據你的程式而修正的程式碼:
#include
#include
#include//基本運算可以不用引入math.h
using namespace std;
int main(int argc,char *argv[])
{
int M,D,S;
while(cin>>M,cin>>D)
{
S=((M*2+D)%3);
if (S==0)
{
cout << "普通"<< endl;
}
else if (S==1)
{
cout << "吉"<< endl;
}
else if (S==2)
{
cout << "大吉"<< endl;
}
}
system("PAUSE");//上傳記得抹掉
return 0;
}
謝謝大大喔~