C++ 1083:計算星期幾

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

int main(){
	int n=1;
	int a=1,b=1;
	cin>>a>>b;
	for(int i=0;i<b;i++){
		n=n*a;
		n=n%7;
	}	
	if(n==1){
		cout<<"Monday";
	} else if(n==2){
		cout<<"Tuesday";
	}else if(n==3){
		cout<<"Wednesday";
	}else if(n==4){
		cout<<"Thursday";
	}else if(n==5){
		cout<<"Friday";
	}else if(n==6){
		cout<<"Saturday";
	}else if(n==0){
		cout<<"Sunday";
	}
	
	
	
	return 1;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章