本文介绍了如何在2月的日历中输出一个月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <iostream>
#include <iomanip>
using namespace std;


int main()


{

	int year;
	int leapyear;
	int month;
	int output_month;




cout << "Calendar Program for Spain " << endl << endl;
cout << "Please enter the year: ";
cin >> year;
	}
	return 0;


int month()
	{



	if (month ==1)
		cout<< "The month is January";
	else if (month==2)
		cout<< "The month is February";
	else if (month==3)
		cout<<"The month is March";
	else if (month==4)
		cout<<"The month is April";
	else if (month==5)
		cout<<"The month is May";
	else if (month==6)
                cout<<"The month is June";
	else if (month==7)
		cout<<"The month is July";
	else if (month==8)
		cout<<"The month is August";
	else if (month==9)
		cout<<"The month is September";
	else if (month==10)
		cout<<"The month is October";
	else if (month==11)
		cout<<"The month is November";
	else if (month==12)
		cout<<"The month is December";
	else
		cout<<" number must be between  1-12.";


int days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

int leapyear()


if(year%400 ==0 || (year%100 != 0 && year%4 == 0))
    {

        isleapyear=true;

    else

        isleapyear=false;

	}

output_month()


	cout << "\n February     Sun  Mon  Tue  Wed  Thu  Fri  Sat\n";
}		}

return 0;</iomanip></iostream>





(复制自评论:)

编写一个包含函数的程序名为no_in_month,将返回2月份的天数(int不是字符串)。用户在main()中输入年份,并在调用时传递给函数。如果年份可以被4整除,则会发生闰年(2月29天)。但是,闰年不会发生在几个世纪末,而这些年份不能被400整除,例如1700年,1800年,1900年不是闰年,而是1600年,2000年。那个问题



( copied from comment: )
Write a program, that incorporates a function called no_in_month that will return the number of days (an int not a string) in the month of February. The year is input by the user in main() and passed to the function when it is called. A leap year (29 days in February) occurs if the year is evenly divisible by 4. However, leap years do not occur at the end of centuries which are not evenly divisible by 400, e.g. the years 1700, 1800, 1900 are not leap years but 1600, 2000 are. that question

推荐答案


这篇关于如何在2月的日历中输出一个月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 22:34