提交记录 #89
提交时间:2024-11-02 15:52:03
语言:c
状态:Unaccepted
编译情况:编译成功
code.c: In function ‘main’:
code.c:3:5: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
3 | scanf("%d",&year);
| ^~~~~
code.c:3:5: warning: incompatible implicit declaration of built-in function ‘scanf’
code.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
+++ |+#include <stdio.h>
1 | int main(){
code.c:19:9: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
19 | printf("There is 1 Black Friday in year %d.\n",year);
| ^~~~~~
code.c:19:9: warning: incompatible implicit declaration of built-in function ‘printf’
code.c:19:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
code.c:24:9: warning: incompatible implicit declaration of built-in function ‘printf’
24 | printf("There are %d Black Fridays in year %d.\n",count,year);
| ^~~~~~
code.c:24:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
固定测试点#1:
固定测试点#2:
固定测试点#3:
附加测试点暂不可用
27【日期】黑色星期五——可以不用数组
int main(){
int year;
scanf("%d",&year);
int count=0;
int date[10];
for (int month = 1; month <= 12; month++) {
int day = 13;
int century = year / 100;
int yearOfCentury = year % 100;
int weekday = (day + (13 * (month + 1)) / 5 + yearOfCentury + (yearOfCentury / 4) + (century / 4) - 2 * century) % 7;
if(weekday==5){
date[count]=month;
count++;
}
}
if(count==1){
printf("There is 1 Black Friday in year %d.\n",year);
printf("It is:\n");
printf("%d/%d/13\n",year,date[0]);
}
if(count>1){
printf("There are %d Black Fridays in year %d.\n",count,year);
printf("They are:\n");
for (int i = 0; i < count; i++) {
printf("%d/%d/13\n",year,date[i]);
}
}
return 0;}