输入1到7之间的值,输出星期几,其它值则退出程序。
c 语言程序如下:
#include <stdio.h>
int main()
{
char s[8][16]={" ","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday","Sunday" };
int i;
while(1){
printf("input one int value between 1 to 7, other value exit:");
scanf("%d",&i);
if (i<=0 || i>7) return 0;
printf("%s\n\n",s[i]);
}
return 0;
}