zoukankan      html  css  js  c++  java
  • 在函数体的“出口处”,对 return 语句的正确性和效率进行检查

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

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

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

     1 #include <iostream>
     2 #include <time.h>
     3 
     4 using namespace std;
     5 
     6 //main()函数的定义
     7 
     8 int main(int argc, char** argv) {
     9  //声明time_t类型的变量,其以秒为单位存放系统时间
    10     time_t current_time;
    11 
    12     //得到当前的系统时间(秒)
    13     time(&current_time); 
    14 
    15     //转换系统时间为tm结构的时间信息
    16     tm  *ptime=gmtime(&current_time);
    17 
    18     //显示time_t结构的时间
    19     cout<<"current_time:"<<current_time<<endl;
    20 
    21     //显示tm结构的时间信息
    22     cout<<"seconds after the minute:"<<(ptime->tm_sec)<<endl;
    23     cout<<"minutes after the hour:"<<(ptime->tm_min)<<endl; 
    24     cout<<"hours since midnight:"<<(ptime->tm_hour)<<endl;  
    25     cout<<"day of the month:"<<(ptime->tm_mday)<<endl;  
    26     cout<<"months since January:"<<(ptime->tm_mon)<<endl; 
    27     cout<<"years since 1900:"<<(ptime->tm_year)<<endl; 
    28     cout<<"days since Sunday:"<<(ptime->tm_wday)<<endl; 
    29     cout<<"days since January 1:"<<(ptime->tm_yday)<<endl; 
    30     cout<<"daylight savings time flag:"<<(ptime->tm_isdst)<<endl;
    31 }
  • 相关阅读:
    去哪儿网门票数据爬虫更新
    每周进度总结12
    每日进度总结20
    每日进度总结19
    每日进度总结18
    每日进度总结17
    每日进度总结16
    每日进度总结15
    每日进度总结14
    每周进度总结11
  • 原文地址:https://www.cnblogs.com/borter/p/9413604.html
Copyright © 2011-2022 走看看