这个题目怎么理解?
我的理解好像行不通#include <stdio.h>
#include <stdlib.h>
int main()
{
int stuNum=0,remainder=-1,weekNum=0;
printf("请输入学号([142011001,142015000>):");
scanf("%d",&stuNum);
if (stuNum>=142011001 && stuNum<142015000){
printf("请输入周数():");
scanf("%d",&weekNum);
if(weekNum>= 1 && weekNum<20){
remainder=stuNum%10;
switch(remainder%3){
case 0:
if(weekNum%3==0){
printf("学生%10d在第%3d周交作业吗?是\n",stuNum,weekNum);
}else{
printf("学生%10d在第%3d周交作业吗?否\n",stuNum,weekNum);
}
break;
case 1:
if(weekNum%3==1){
printf("学生%10d在第%3d周交作业吗? 是\n",stuNum,weekNum);
}else{
printf("学生%10d在第%3d周交作业吗?否\n",stuNum,weekNum);
}
break;
case 2:
if(weekNum%3==2){
printf("学生%10d在第%3d周交作业吗?是\n",stuNum,weekNum);
}else{
printf("学生%10d在第%3d周交作业吗?否\n",stuNum,weekNum);
}
break;
}
}else
printf("周数输入错误,应该在内");
}else
printf("学号输入错误,应该在[142011001,142015000>内");
return 0;
}
remainder=stuNum%10;
remainder%3
weekNum%3
关键 就是 这个 取余操作 其他都不重要
页:
[1]