#include"stdio.h"
char xq[7][10]={"星期一","星期二","星期三","星期四","星期五","星期六","星期日"};
void get_result(int day){
int day_after100;//用来保存100后是星期几
day_after100=(day-1+100%7)%7;//计算100天后是星期几
printf("100天后是:%s\n",xq[day_after100]);//输出结果
}
void main(){
int day;
printf("今天是星期几:");
scanf("%d",&day);
while(day<1||day>7){
printf("必须是1至7之间的一个数,请重新输入:");
scanf("%d",&day);
}//当输入的数据不满足规则时,循环输入直到满足规则为止
get_result(day);
}
#include
void main()
{
int i;
char a[][20]={"打酱油路过","星期1","星期2","星期3","星期4","星期5","星期6","星期天"};
enum xx{x1=1,x2,x3,x4,x5,x6,xt}q,w;
while(1)
{
printf("请输入今天星期几");
scanf("%d",&q);
if(q>0&&q<7)
{
break;
}
printf("请输入正确星期编号\n");
}
printf("请输入天数\n");
scanf("%d",&i);
w=enum xx((q+i)%7);
printf("%s",a[q]);
printf("%d天后为%s",i,a[w]);
}
用SWITCH语句和整除就可以了