document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
  5.  
  6. bool checkYear(int year)
  7. {
  8. return year > 0;
  9. }
  10.  
  11. bool checkMonth(int month)
  12. {
  13. return (month>0 && month<13);
  14. }
  15.  
  16. bool isLeapYear(int year)
  17. {
  18. return (year%4==0) && (year%100!=0) || (year%400==0);
  19. }
  20.  
  21. int getDays(int year, int month)
  22. {
  23. switch(month)
  24. {
  25. case 2: return days[month]+isLeapYear(year);
  26. default: return days[month];
  27. }
  28. }
  29.  
  30. bool checkDay(int year, int month, int day)
  31. {
  32. return (day>0)&&(day<=getDays(year, month));
  33. }
  34.  
  35. int main()
  36. {
  37. int year, month, day;
  38.  
  39. while(cin >> year >> month >> day)
  40. {
  41. if( checkYear(year) && checkMonth(month) && checkDay(year, month, day) )
  42. {
  43. int ans = 0;
  44. for(int i=1; i<month; i++)
  45. {
  46. ans += days[i];
  47. }
  48. ans += day;
  49. if(ans>1)
  50. cout << "It is " << ans << " days in " << year << endl;
  51. else
  52. cout << "It is " << ans << " day in " << year << endl;
  53. }
  54. else
  55. cout << "Error" << endl;
  56. }
  57.  
  58. }
');