编制程序实现输入一个1~7之间的数字,输出相应的星期几,如输入1,则输出星期一

如题所述

#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");
}
}
温馨提示:内容为网友见解,仅供参考
第1个回答  2019-07-13
python:
n = eval(input("输入一个1~7之间的数字:"))
n = n-1
a=["星期一","星期二","星期三","星期四","星期五","星期六","星期日"]
print(a[n])
第2个回答  2008-12-10
'新建一个 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本回答被网友采纳
第3个回答  2008-12-10
用循环,do ....case
相似回答