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

📄 date.h

📁 c++实现的对电话进行计费的系统
💻 H
字号:
//*****************************
//****      Date.h         ****
//*****************************
#include<iostream.h>
class DateTime{
	public: int year;
			int month;
			int date;
			int hour;
			int minute;
			int second;
	bool key;
	DateTime(){
		key=true;
		cout<<"请输入年份:";
		cin>>year;
		cout<<"请输入月份:";
		cin>>month;
		while(month<1 || month>12){
			cout<<"输入有误,请重新输入:";
			cin>>month;
			}
		cout<<"请输入日期:";
		cin>>date;
		while(date>31 || date<1){
			cout<<"输入有误,请重新输入:";
			cin>>date;
		}
		while(key){
			if (month==4 || month==6 || month==9 || month==11){
				if(date==31){
					cout<<"小月没有31号,请重新输入:";
					cin>>date;}
				else key=false;
			}
			else if (month==2){
				if((year%4==0 && year%100 !=0) || year%400==0){
					if (date>29){
						cout<<"闰年2月只有29天,请重新输入:";
						cin>>date;
					}
					else key=false;
				}
				else if(date>28) {
					cout<<"平年2月只有28天,请重新输入:";
					cin>>date;
				}
				else key=false;
			}
			else key=false;
		}
		cout<<"请输入小时:";
		cin>>hour;
		while(hour<0 || hour>23){
			cout<<"输入有误,请重新输入:";
			cin>>hour;
			}
		cout<<"请输入分钟:";
		cin>>minute;
		while(minute<0 || minute>60){
			cout<<"输入有误,请重新输入:";
			cin>>minute;
			}
		cout<<"请输入秒:";
		cin>>second;
		while(second<0 || second>60){
			cout<<"输入有误,请重新输入:";
			cin>>second;
			}

	}
		
	
};

⌨️ 快捷键说明

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