题解|#水题再次来袭:明天星期几?#

水题再次来袭:明天星期几?

https://ac.nowcoder.com/acm/problem/21310

根据题意就是输出明天是星期几,唯一要注意的一点是周7的下一天是周一

#include <iostream>
using namespace std;
int main()
{
    int x;
    cin >> x;
    if(x==7)
        x=0;
    cout << x+1;
}
import java.util.Scanner ;

public class Main{
    public static void main(String[] args){
        int[] a = {1,2,3,4,5,6,7} ;
        int x ;
        Scanner sc = new Scanner(System.in) ;
        x = sc.nextInt() ;
        System.out.println(a[x%7]) ;
    }
}
a = int(input())
if a < 7:
    print(a+1)
else:
    print(1)
全部评论

相关推荐

06-05 19:46
已编辑
武汉大学 后端
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务