Go: package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

C++: #include <cstdio>

using namespace std;

bool testcase_ends() {
    int m, d;
    scanf("%d %d", &m, &d);

    if (m == 0 && d == 0)
        return 1;

    int offset[]={
        0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335
    };

    const char *day[]={
        "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "Sun"
    };

    printf("%sday\n", day[(offset[m-1]+d+2)%7]);
    return 0;
}

int main() {
    int solved=0;
    while (!testcase_ends())
        ++solved;

    return !solved;
}

C++: #include <iostream>
using namespace std;

int main()
{
	int month[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d;
	while(cin >> m >> d){
		if(m==0&&d==0)
			break;
		int day=0;
		for(int i=1;i<m;i++){
			day+=month[i];
		}
		day+=d;
		switch(day%7){
			case 0:
				cout << "Wednesday" << endl;
				break;
			case 1:
				cout << "Thursday" << endl;
				break;
			case 2:
				cout << "Friday" << endl;
				break;
			case 3:
				cout << "Saturday" << endl;
				break;
			case 4:
				cout << "Sunday" << endl;
				break;
			case 5:
				cout << "Monday" << endl;
				break;
			case 6:
				cout << "Tuesday" << endl;
				break;
			default:
				break;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector> 
#include <math.h>
#include <stdio.h>
using namespace std;

double r(double x1,double y1,double x2,double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	
	}

int main() {
	// your code goes here
int a[13];
a[1]=31;
a[2]=29;
a[3]=31;
a[4]=30;
a[5]=31;
a[6]=30;
a[7]=31;
a[8]=31;
a[9]=30;
a[10]=31;
a[11]=30;
a[12]=31;

int m,d,z,y;
cin>>m>>d;
while(m!=0){
	if(m==0) z=d;
	else{
		z=d;
		for(int i=1;i<m;i++){
			z=z+a[i];
		}
	}
	y=z%7;
	if(y==1){
		cout<<"Thursday"<<endl;
	}
		if(y==2){
		cout<<"Friday"<<endl;
	}
		if(y==3){
		cout<<"Saturday"<<endl;
	}
		if(y==4){
		cout<<"Sunday"<<endl;
	}
		if(y==5){
		cout<<"Monday"<<endl;
	}
		if(y==6){
		cout<<"Tuesday"<<endl;
	}
		if(y==0){
		cout<<"Wednesday"<<endl;
	}

C++: #include <iostream>
#include <string>
using namespace std;

int main() {
  int days[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
  string youbi[7] = {"Monday","Tuesday","Wednesday","Thursday",
		     "Friday","Saturday","Sunday"};
  while(1) {
    int mon, day;
    cin >> mon >> day;
    if(mon == 0) break;

    int sum = 0;
    for(int i = 0; i < mon-1; i++) {
      sum += days[i];
    }
    sum += day;

    cout << youbi[(sum+2)%7] << endl;
  }
  return 0;
}

C++: // Zellerの公式

#include <iostream>
#include <cstring>
using namespace std;

string Day[] = {
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
};

void Day2004(int month, int day);

int main(void) {
    int month, day;
    
    while(cin >> month >> day) {
        if(month == 0 || day == 0) {
            break;
        }
        Day2004(month, day);
    }
}

void Day2004(int month, int day) {
    int y, m, d;
    int DayNumber;
    
    if(month == 1 || month == 2) {
        y = 2003;
        m = month + 12;
        d = day;
    } else {
        y = 2004;
        m = month;
        d = day;
    }
    
    DayNumber = 
        (y + (y / 4) - (y / 100) + (y / 400) + ((13 * m + 8) / 5) + d) % 7;
    
    cout << Day[DayNumber] << endl;
}

C++: #include <stdio.h>

int total[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};

int Sum(int x) {
  int i, sum = 0;
  for(i = 0; i < x; i ++) {
    sum += total[i];
  }

  return sum;
}

int main() {
  int month, day;
  while(scanf("%d %d", &month, &day)) {
    if(month == 0) break;

    switch((Sum(month - 1) + day)%7) {
      case 0:
        printf("Thursday\n");
        break;

      case 1:
        printf("Friday\n");
        break;

      case 2:
        printf("Saturday\n");
        break;

      case 3:
        printf("Sunday\n");
        break;

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
  int d[]={31,29,31,30,31,30,31,31,30,31,30,31};
  string s[]={"Thursday",
	      "Friday","Saturday","Sunday","Monday","Tuesday","Wednesday",};
  int i,j;
  int a,b;
  cin>>a>>b;
  while(a!=0){
    int o=0;
    for(i=1;i<a;i++) o+=d[i-1];
    o+=b-1;
    //cout << o << endl;
    cout << s[o%7] << endl;
    cin>>a>>b;
  }
  return 0;
}

C++: #include <iostream>
#include <ctime>
using namespace std;

int main()
{
    string weeks[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

    struct tm  t;
    t.tm_year  = 2004 - 1900;
    t.tm_hour  = 0;
    t.tm_min   = 0;
    t.tm_sec   = 0;
    t.tm_isdst = 0;

    for (int month, day; cin >> month >> day && (month || day);) {
        t.tm_mon   = month - 1;
        t.tm_mday  = day;
        mktime(&t);
        cout << weeks[t.tm_wday] << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
    string m = "Monday", tu = "Tuesday", w = "Wednesday", th = "Thursday", f = "Friday",
        sa = "Saturday", su = "Sunday";
    while(1) {
        int a=0, b=0;
        cin >> a >> b;
        if(a == 0 && b == 0)
            return 0;

        switch(a) {
        case 12:
            b += 30;
        case 11:
            b += 31;
        case 10:
            b += 30;
        case 9:
            b += 31;
        case 8:
            b += 31;
        case 7:
            b += 30;
        case 6:
            b += 31;
        case 5:
            b += 30;
        case 4:
            b += 31;
        case 3:
            b += 29;
        case 2:
            b += 31;
        default:
            ;
        }
        //cout << b << ' ';
        if(b % 7 == 0)
            cout << w << endl;
        if(b % 7 == 1)
            cout << th << endl;
        if(b % 7 == 2)
            cout << f << endl;
        if(b % 7 == 3)
            cout << sa << endl;
        if(b % 7 == 4)
            cout << su << endl;
        if(b % 7 == 5)
            cout << m << endl;
        if(b % 7 == 6)
            cout << tu << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(){
int m,d,h,y=4;
char w[][7]={"Satur","Sun","Mon","Tues","Wednes","Thurs","Fri"};
for(;;){
cin>>m>>d;
if(m==0)break;
if(m<3){m+=12;y--;}
h=(y+int(y/4)-35+int(2.6*(m+1))+d)%7;
cout<<w[h]<<"day"<<endl;
}
return 0;
}

C++: #include <iostream>
#include <string>

using namespace std;

int main() {
    int m, d, past = 0;
    int day[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    string week[] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };
    while (cin >> m >> d, m != 0) {
        for (int i = 0; i < m - 1; i++) {
            past += day[i];
        }
        past += d - 1;
        cout << week[past % 7] << endl;
    }

    return 0;
}