L1-024 后天 (5分)
如果今天是星期三,后天就是星期五;如果今天是星期六,后天就是星期一。我们用数字 (1) 到 (7) 对应星期一到星期日。给定某一天,请你输出那天的“后天”是星期几。
输入格式:
输入第一行给出一个正整数 (D ; (1 leq D leq 7)),代表星期里的某一天。
输出格式:
在一行中输出 (D) 天的后天是星期几。
输入样例:
3
输出样例:
5
代码:
#include<bits/stdc++.h>
using namespace std;
int d,ans;
int main()
{
cin>>d;
ans=d+2;
ans%=7;
if(!ans)ans=7;
cout<<ans<<endl;
return 0;
}