程式碼:
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
int test; //輸入數量.
int month; //幾月.
int day; //幾號.
int sum;// 總和天數.
int imonth[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; //12個月
string Week[7] = {"Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday"};
int date;
int i,j; //控制迴圈.
int main()
{
cin>>test;
for(i=0;i<test;i++)
{
sum=0;
cin>>month>>day;
for(j=1;j<month;j++)
sum=sum+imonth[j]; //前面月份日子總和
sum=sum+day; //當月日子總和
date = sum %7;
cout<<Week[date]<<endl;
}
return 0;
}
沒有留言:
張貼留言
歡迎指教或發問