首页 > 试题广场 >

明天星期几?

[编程题]明天星期几?
  • 热度指数:21728 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 256M,其他语言512M
  • 算法知识视频讲解
\hspace{15pt}我们以整数 1\sim7 分别表示星期一到星期天。已知今天是星期 d,请你推算明天是星期几。

输入描述:
\hspace{15pt}在一行中输入一个整数 d1 \leqq d \leqq 7),表示今天是星期 d


输出描述:
\hspace{15pt}输出一个整数,表示明天是星期几(范围同样为 1\sim7)。
示例1

输入

1

输出

2

说明

今天为星期一(1),明天为星期二(2)。

备注:
本题已于下方时间节点更新,请注意题解时效性:
1. 2025-06-03 优化题面文本与格式。
#include <iostream>
using namespace std;

int main() {
   int d;
   cin >> d;
   cout << d%7+1;
}
发表于 2025-09-12 02:15:13 回复(0)
 
#include <stdio.h>

int main() {
    int day;

    scanf("%d", &day);

    if (day == 1) printf("2");
    if (day == 2) printf("3");
    if (day == 3) printf("4");
    if (day == 4) printf("5");
    if (day == 5) printf("6");
    if (day == 6) printf("7");
    if (day == 7) printf("1");

    return 0;
}
发表于 2025-06-24 20:17:44 回复(1)
#include <stdio.h>

int main() {
    int d;
    scanf("%d",&d);
    switch (d) {
    case 1:printf("2");break;
    case 2:printf("3");break;
    case 3:printf("4");break;
    case 4:printf("5");break;
    case 5:printf("6");break;
    case 6:printf("7");break;
    case 7:printf("1");break;
    }
    return 0;
}
发表于 2025-10-02 23:51:11 回复(0)
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    cout << n % 7 + 1 << endl;

    return 0;
}

发表于 2025-12-08 02:00:47 回复(0)
d=int(input())
less_7=d<7
if less_7:
    print(d+1)
else:
    print(1)

发表于 2025-10-27 15:01:58 回复(0)

from re import T
d = int(input())
tomorrow = d+1
if tomorrow > 7:
    print(tomorrow-7)
    exit()
print(int(tomorrow))

 

发表于 2025-07-24 10:06:13 回复(0)
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = a % 7;
            System.out.println(b + 1);
        }
    }
}
发表于 2025-06-06 14:47:21 回复(0)
a = input()
a = int(a)#这是因为字符型的a不能当作数字进行运算
if a == 7:
    print("1")
else:
    b = a + 1
    print(b)
发表于 2025-12-19 15:34:34 回复(0)
d = int(input())
if 1<=d<=6 :
    print(d+1)
else:
    print("1")
发表于 2025-12-17 18:17:35 回复(0)
n = int(input())
if n<7:
    x = 0
    x = n+1
    print(x)
else:
    print(n+1-7)
发表于 2025-12-08 11:27:31 回复(0)
int main() {
    int a;
    cin >> a;
    cout << a % 7 + 1;
}

发表于 2025-12-06 10:47:36 回复(0)
#include <stdio.h>

int main() 
{
    int d;
    scanf("%d", &d);
    
    if (d <= 0 || d >= 8)
    {
        printf("输入错误!!!\n");
    }
    else if (d == 7) 
    {
        printf("%d\n",1);
    }
    else 
    {
        printf("%d\n", d + 1);
    }
    return 0;
}
本着方便看的想法加入了中文“明天是星期”结果不对hhh
发表于 2025-11-19 17:39:52 回复(0)
d = int(input())
if d==7:
    x = 1
else:
    x = d+1
print(x)

发表于 2025-11-09 22:39:08 回复(0)
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        //使用Scanner输入今天星期几
        Scanner sc=new Scanner(System.in);
        //定义一个整数d,表示今天星期几
        int d=sc.nextInt();
        if(1<=d&&d<=6){
            d++;
            System.out.println(d);
        }else{
            System.out.println(1);
        }
    }
}
发表于 2025-10-31 15:49:25 回复(0)
#include <iostream>
using namespace std;

int main() {
    int a;
    cin>>a;
    if(a<7)cout<<a+1;
    else cout<<1;
}
发表于 2025-10-28 23:10:40 回复(0)
#include <iostream>
using namespace std;

int main()
{
    int d=0;
    cin>>d;
    cout<<d%7+1;
}
发表于 2025-10-26 16:56:30 回复(0)
#include <stdio.h>

int main()
{
    int x;
    scanf("%d",&x);
    if(x<=6)
    {
        printf("%d",++x);
    }
    else {
    printf("%d",1);
    }
    return 0;
发表于 2025-10-26 16:18:30 回复(0)
#include <iostream>
using namespace std;

int main() {
    int num;
    cin>>num;

    if(num>=1 && num<=7)
    {
        switch(num)
            {
                case 0:
                cout<<++num<<endl;
                break;

                case 1:
                cout<<++num<<endl;
                break;

                case 2:
                cout<<++num<<endl;
                break;

                case 3:
                cout<<++num<<endl;
                break;

                case 4:
                cout<<++num<<endl;
                break;

                case 5:
                cout<<++num<<endl;
                break;

                case 6:
                cout<<++num<<endl;
                break;

                case 7:
                cout<<1<<endl;
                break;
            }
    }
}
// 64 位输出请用 printf("%lld")
发表于 2025-10-18 10:44:03 回复(1)
#include <stdio.h>

int main() {
    int d = 0;

    scanf("%d", &d);

    if (d <= 0 || d >= 8) {    //成绩输入限制,不大于100,且为10的倍数

        printf("输入的日期超过范围,请重新输入\r\n");

        return -1;

    } else if (d == 7) {

        printf("%d", 1);
    }

    else {

        printf("%d", d + 1);

    }

    return 0;
}
发表于 2025-10-12 11:38:45 回复(0)
//友友们
#include <stdio.h>

int main() {
    int d;
    scanf("%d",&d);
    if(d==7){
        d=1;
    }
    else{
        d+=1;
    }
    printf("%d\n",d);
    return 0;
}
发表于 2025-09-28 16:28:24 回复(0)