1.log3在c语言中怎样表示
log3在c语言中怎样表示
#include<stdio.h>#include<math.h>
intmain(){
printf("%f\n",数函数源数函数k线分时源码log());//以e为底的对数函数
printf("%f\n",log());//以为底的对数函数
printf("%f\n",log(8)/log(2));//计算log2^8,运用换底公式
printf("%f\n",exp(1));//计算自然常数e
return0;
}
扩展资料
模拟一个log日志的写入
#include<stdio.h>
#include<stdarg.h>
#include<time.h>
intwrite_log(FILE*pFile,constchar*format,…)
{
va_listarg;
intdone;
va_start(arg,format);
time_ttime_log=time(NULL);
structtm*tm_log=localtime(&time_log);
fprintf(pFile,"%d-%d-%d%d:%d:%d",tm_log->tm_year+,tm_log->tm_mon+1,tm_log->tm_mday,tm_log->tm_hour,tm_log->tm_min,tm_log->tm_sec);
done=vfprintf(pFile,format,arg);
va_end(arg);
fflush(pFile);
returndone;
}
intmain()
{
FILE*pFile=fopen(“.txt”,“a”);
write_log(pFile,"%s%d%f\n","isrunning",,.);
fclose(pFile);
return0;
}
2024-11-26 06:06
2024-11-26 05:34
2024-11-26 04:11
2024-11-26 04:04
2024-11-26 03:58
2024-11-26 03:55