编制程序实现输入一个1~7之间的数字,输出相应的星期几,如输入1,则输出星期一 5
4个回答
展开全部
#include <stdio.h>
void main(){
int n;
printf("请输入一个1~7之间的数字:");
scanf("%d",&n);
switch(n){
case 1:printf("星期一\n");break;
case 2:printf("星期二\n");break;
case 3:printf("星期三\n");break;
case 4:printf("星期四\n");break;
case 5:printf("星期五\n");break;
case 6:printf("星期六\n");break;
case 7:printf("星期七\n");break;
default:printf("输入有错!\n");
}
}
void main(){
int n;
printf("请输入一个1~7之间的数字:");
scanf("%d",&n);
switch(n){
case 1:printf("星期一\n");break;
case 2:printf("星期二\n");break;
case 3:printf("星期三\n");break;
case 4:printf("星期四\n");break;
case 5:printf("星期五\n");break;
case 6:printf("星期六\n");break;
case 7:printf("星期七\n");break;
default:printf("输入有错!\n");
}
}
展开全部
python:
n = eval(input("输入一个1~7之间的数字:"))
n = n-1
a=["星期一","星期二","星期三","星期四","星期五","星期六","星期日"]
print(a[n])
n = eval(input("输入一个1~7之间的数字:"))
n = n-1
a=["星期一","星期二","星期三","星期四","星期五","星期六","星期日"]
print(a[n])
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
'新建一个 text1 和一个 text2
Private Sub Text1_Change()
Select Case Text1.Text
Case Is = 1
Text2.Text = "星期一"
Case Is = 2
Text2.Text = "星期二"
Case Is = 3
Text2.Text = "星期三"
Case Is = 4
Text2.Text = "星期四"
Case Is = 5
Text2.Text = "星期五"
Case Is = 6
Text2.Text = "星期六"
Case Is = 7
Text2.Text = "星期日"
Case Else
Text2.Text = ""
End Select
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Text1.Text = ""
End Sub
Private Sub Text1_Change()
Select Case Text1.Text
Case Is = 1
Text2.Text = "星期一"
Case Is = 2
Text2.Text = "星期二"
Case Is = 3
Text2.Text = "星期三"
Case Is = 4
Text2.Text = "星期四"
Case Is = 5
Text2.Text = "星期五"
Case Is = 6
Text2.Text = "星期六"
Case Is = 7
Text2.Text = "星期日"
Case Else
Text2.Text = ""
End Select
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Text1.Text = ""
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用循环,do ....case
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询