如何在2月的日历中输出一个月 [英] How Do I Output One Month In Calendar For Feburary

查看:78
本文介绍了如何在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

推荐答案

你的代码包含很多与你给出的任务无关的东西。然而,它确实错过了许多其他要求包括的内容:



1.一个名为 no_in_month 将在Februar月份返回天数( int 而不是字符串) br />


2.用户在main()中输入年份(您需要添加从标准输入中读取年份的代码)



3.此外,虽然没有明确说明,但您应输出2月份的天数,计算方法为 no_in_month



打印给定年份的整个日历似乎不属于您的任务。
Your code contains a lot of stuff that isn't related to the task you have been given. It does however miss a lot of other things that you have been asked to include:

1. "a function called no_in_month that will return the number of days (an int not a string) in the month of Februar"

2. "The year is input by the user in main()" (you need to add code that reads the year from standard input)

3. Also, while not explicitely stated, you should output the number of days in february as computed in no_in_month

Printing an entire calender for a given year doesn't appear to be part of your assignment.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆