⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data.cpp

📁 软件课程设计(1) 是一些非常经典的程序
💻 CPP
字号:
#include <iostream>
using namespace std;
#include "datatype.h"
#include <stdlib.h>

bool DataType::leapYear(int year)
{
	if((year%4 ==0&&year%100 !=0)||year%400 ==0) return true;
	else return false;
}
      
void DataType::increaseDay()
{   
	int n;
	cout<<"请输入每次要增加的天数:      ";
	cin>>n;
	int limit;
	switch (month)
	{
	case 1:case 3:case 5:case 7:case 8:case 10:case 12:limit=31;break;
	case 4:case 6:case 9:case 11:limit=30;break;
	case 2:if(leapYear(year)) limit=29;else limit=28;
	}
    for(int i=1;i<=n;i++)
	{
		day=day+1;
		if(day>limit)
		{
			month=month+1;day=1;
			if(month>12) {year=year+1;month=1;}
		}
		
			
	}
	
}  

          
bool DataType::equa()
{
	cout<<"请输入另一个日期:\n";
	DataType  dd1;
	cin>>dd1;
	if (day==dd1.day&&dd1.month==month&&dd1.year==year) {cout<<"两日期相等\n";return true;}
		else {cout<<"两日期不相等 \n"; return false;}
} 


                     
 istream& operator >> ( istream&input,DataType&d)
 {
	cout<<"请输入日期:年,月,日(数字格式):\n";
    input>>d.year>>d.month>>d.day;
    return input;
 }


 ostream& operator << ( ostream&output,DataType&d)
{
   output<<d.year<<"--"<<d.month<<"--"<<d.day<<endl;
   return output;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -