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

📄 timesyshms.cc

📁 c++编写的并行拉马克遗传算法的程序。实现分析对接程序
💻 CC
字号:
/* timesyshms.cc */#ifdef sgi    #include <stdio.h>    #include <sys/types.h>    #include <sys/times.h>    #include <time.h>    #include <unistd.h>    #include "timesyshms.h"#else    extern "C"    {	#include <stdio.h>	#include <sys/types.h>	#include <sys/times.h>	#include <time.h>	#include <unistd.h>        #include "timesyshms.h"    }#endifextern  FILE    *logFile;extern	float	idct;/*----------------------------------------------------------------------------*/void timesyshms( Clock  duration,		 struct tms *start,		 struct tms *end )/*----------------------------------------------------------------------------*/{    int   h,          m;    float t,	  T,	  s;    const float min = 60.,                hrs = 3600.;     (void)fprintf( logFile, "Real= " );    t = (float)duration * idct;    h = (int)(t/hrs);    T = t - ((float)h)*hrs;    m = (int)(T/min);    s = T - ((float)m)*min;    if (h == 0) {        if (m == 0)            (void)fprintf(logFile,       "%.2fs",       s );        else            (void)fprintf(logFile,    "%dm %05.2fs",    m, s );    } else {            (void)fprintf(logFile, "%dh %02dm %05.2fs", h, m, s );    }    (void)fprintf( logFile, ",  CPU= " );    t = (float)((end->tms_utime  - start->tms_utime) * idct);    h = (int)(t/hrs);    T = t - ((float)h)*hrs;    m = (int)(T/min);    s = T - ((float)m)*min;    if (h == 0) {        if (m == 0)            (void)fprintf(logFile,       "%.2fs",       s );        else            (void)fprintf(logFile,    "%dm %05.2fs",    m, s );    } else {            (void)fprintf(logFile, "%dh %02dm %05.2fs", h, m, s );    }    (void)fprintf( logFile, ",  System= " );    t = (float)((end->tms_stime  - start->tms_stime) * idct);    h = (int)(t/hrs);    T = t - ((float)h)*hrs;    m = (int)(T/min);    s = T - ((float)m)*min;    if (h == 0) {        if (m == 0)            (void)fprintf(logFile,       "%.2fs",       s );        else            (void)fprintf(logFile,    "%dm %05.2fs",    m, s );    } else {            (void)fprintf(logFile, "%dh %02dm %05.2fs", h, m, s );    }    (void)fprintf( logFile, "\n" );}/*----------------------------------------------------------------------------*//* EOF.                                                                       *//*----------------------------------------------------------------------------*/

⌨️ 快捷键说明

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