fork download
  1. #pragma GCC optimize ("Ofast")
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. inline int isLeapYear(const int y){
  5. if(y%4){
  6. return 0;
  7. }
  8. if(y%100){
  9. return 1;
  10. }
  11. if(y%400){
  12. return 0;
  13. }
  14. return 1;
  15. }
  16. inline int numOfDaysInMonth(const int m){
  17. if(m==2){
  18. return 28;
  19. }
  20. if(m==4||m==6||m==9||m==11){
  21. return 30;
  22. }
  23. return 31;
  24. }
  25. inline int numOfDaysInMonth(const int y, const int m){
  26. if(m==2){
  27. return numOfDaysInMonth(m)+ isLeapYear(y);
  28. }
  29. else{
  30. return numOfDaysInMonth(m);
  31. }
  32. }
  33. #define main dummy_main
  34. int main(){
  35. return 0;
  36. }
  37. #undef main
  38. class Solution{
  39. public:
  40. int dayOfYear(string date){
  41. int d, i, m, res=0, y;
  42. y = atoi(date.c_str());
  43. m = atoi(date.c_str()+5);
  44. d = atoi(date.c_str()+8);
  45. for(i=(1);i<(m);i++){
  46. res += numOfDaysInMonth(y,i);
  47. }
  48. res += d;
  49. return res;
  50. }
  51. }
  52. ;
  53. // cLay varsion 20190818-1
  54.  
  55. // --- original code ---
  56. // #define main dummy_main
  57. // {}
  58. // #undef main
  59. //
  60. // class Solution {
  61. // public:
  62. // int dayOfYear(string date) {
  63. // int y, m, d, res=0, i;
  64. // y = atoi(date.c_str());
  65. // m = atoi(date.c_str()+5);
  66. // d = atoi(date.c_str()+8);
  67. // rep(i,1,m) res += numOfDaysInMonth(y,i);
  68. // res += d;
  69. // return res;
  70. // }
  71. // };
  72.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty