题目:就是给你一个数字,判断周六周日的最多和最少天数。
思路:判断是不是 7 的整数倍,然后依次判断余数
代码参考:
#include<stdio.h>
#include<stdlib.h>
#define G 1000
int main() {
int n,max,min,yu,k;
while(scanf("%d",&n)!=EOF){
k=n%7;//感觉思路挺复杂
if(k==0){
max=min=n/7*2;
printf("%d %d\n",min,max);
}
else if(k<=2){
max=n/7*2+k;
min=n/7*2;
printf("%d %d\n",min,max);
}
else if(k<=6){
max=n/7*2+2;
if(k<6)
min=n/7*2;
else
min=n/7*2+1;
printf("%d %d\n",min,max);
}
}
return 0;
}