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

📄 00008.cpp

📁 通过一些基础的程序
💻 CPP
字号:
/*
名称编号:00008-1
实现功能:时间结构体
运行结果:通过
*/
/***************************************************************/
#include <iostream>
using namespace std;
struct time {int year,month,day;};
void main()
{	struct time eg_time;       //结构体实例化
	cout<<"请输入年份,并单击回车换行"<<endl;  
	cin>>eg_time.year;         //实例调用对象的成员(结构体的成员)
	cin>>eg_time.month;        //实例调用对象的成员(结构体的成员)
	cin>>eg_time.day;	       //实例调用对象的成员(结构体的成员)
	
	cout<<eg_time.year<<"年"   //--------------------------------
		<<eg_time.month<<"月"  //--------------------------------
		<<eg_time.day<<"日"    //--------------------------------
		<<endl;
} 
/***************************************************************/



//【拓展1】加强版
/*
名称编号:00008-2
实现功能:时间结构体
运行结果:通过
*/
/***************************************************************/
#include <iostream>
using namespace std;
struct time
{int year,month,day;};
void main()
{		struct time ti;
		cout<<"请输入年份"<<endl;
		cin>>ti.year;
            aa:	cout<<"请输入月份"<<endl;
		cin>>ti.month;
		if(ti.month<=12&&ti.month>=0)
			goto bb;
		else  {cout<<"请正确输入月份"<<endl;
		goto aa;}
            bb: cout<<"请输入号数"<<endl;
		cin>>ti.day;
		if(ti.day<=31&&ti.day>=0)
			goto cc;
		else {cout<<"请正确输入号数"<<endl;
		goto bb;}
            cc:	cout<<ti.year<<"年"
					<<ti.month<<"月"
					<<ti.day<<"日"<<endl;
} 
/***************************************************************/

⌨️ 快捷键说明

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