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

📄 time.cpp

📁 本程序用C++实现华氏与摄氏温度的转换.函数运算.与系统时间显示
💻 CPP
字号:
#include <iostream.h>
#include <stdlib.h>
#include <time.h>

class Time
{ public:
      void set();
	  void show();
  private:
      int year;
      int month;
      int day;
      int hour;
      int min;
      int sec;};


void Time::show()
{cout<<"当前时间是:"<<year<<"-"<<month<<"-"<<day<<"-"<<hour<<"-"<<min<<"-"<<sec<<endl;}

void Time::set()
{   time_t timer;
	struct tm *p;
	time(&timer);
    p=localtime(&timer);
	year=p->tm_year;
	month=p->tm_mon;
	day=p->tm_mday;
	hour=p->tm_hour;
	min=p->tm_min;
	sec=p->tm_sec;
}

int main()
{    Time ltime;
     ltime.set();
     ltime.show();
     return 0;
}

⌨️ 快捷键说明

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