PAT L1-024. 后天
#include <stdio.h>
int
main() {
int d, ans;
scanf("%d", &d);
ans = (d + 2) % 7; //
if( ans == 0 ) {
printf("7\n");
}
else {
printf("%d\n", ans);
}
return 0;
}
本文介绍了一个简单的C语言程序,该程序用于计算输入日期后的第二天是星期几。通过使用取余运算,程序能够准确地给出答案。
#include <stdio.h>
int
main() {
int d, ans;
scanf("%d", &d);
ans = (d + 2) % 7; //
if( ans == 0 ) {
printf("7\n");
}
else {
printf("%d\n", ans);
}
return 0;
}

被折叠的 条评论
为什么被折叠?