首页 技术 正文
技术 2022年11月18日
0 收藏 356 点赞 3,849 浏览 861 个字

在函数体的“出口处”,对 return 语句的正确性和效率进行检查。

如果函数有返回值,那么函数的“出口处”是 return 语句。

我们不要轻视 return 语 句。如果 return 语句写得不好,函数要么出错,要么效率低下。

 #include <iostream>
#include <time.h> using namespace std; //main()函数的定义 int main(int argc, char** argv) {
//声明time_t类型的变量,其以秒为单位存放系统时间
time_t current_time; //得到当前的系统时间(秒)
time(&current_time); //转换系统时间为tm结构的时间信息
tm *ptime=gmtime(&current_time); //显示time_t结构的时间
cout<<"current_time:"<<current_time<<endl; //显示tm结构的时间信息
cout<<"seconds after the minute:"<<(ptime->tm_sec)<<endl;
cout<<"minutes after the hour:"<<(ptime->tm_min)<<endl;
cout<<"hours since midnight:"<<(ptime->tm_hour)<<endl;
cout<<"day of the month:"<<(ptime->tm_mday)<<endl;
cout<<"months since January:"<<(ptime->tm_mon)<<endl;
cout<<"years since 1900:"<<(ptime->tm_year)<<endl;
cout<<"days since Sunday:"<<(ptime->tm_wday)<<endl;
cout<<"days since January 1:"<<(ptime->tm_yday)<<endl;
cout<<"daylight savings time flag:"<<(ptime->tm_isdst)<<endl;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,038
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,524
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,372
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,152
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,785
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,867