学生个人网页设计主题/系统优化的意义
C++ 功能算法实现
文章目录
- C++ 功能算法实现
- 前言
- 一、基本功能
- 总结
前言
无
一、基本功能
C++ 真随机数生成方法
- “秒”转换成“年月日时分秒”
- “秒”转“年月日时分秒”
//上面链接中网络上的代码解出时间来有些问题,并且起始月份日期只能是1月1日,以下是我修改后的代码int IfLeapYear(int year)
{return (((year%100!=0)&&(year%4==0)) || ((year%100==0)&&(year%400==0)));
}
string Second2Date_2(long long inputSecond)
{//秒数转换int year___d[2] = {365, 366};int year___s[2] = {365*24*60*60,366*24*60*60};int month__d[2][12] = {{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};int day____s = 24*60*60;int hour___s = 60*60;int minute_s = 60;//起始时间int start_year__ = 1996;int start_month_ = 9;int start_day___ = 29;int start_hour__ = 0;int start_minute = 0;int start_second = 0;int out_year__ = start_year__;int out_month_ = 1;int out_day___ = 1;int out_hour__ = 0;int out_minute = 0;long long out_second ;//获取初始秒long long tempSecond = inputSecond;//将 时:分:秒 转化为 00:00:00out_second = tempSecond + start_second+start_minute*minute_s+start_hour__*hour___s;//将月份转化为当年1月for(int i_mon=1;i_mon<start_month_;i_mon++){out_second += month__d[IfLeapYear(start_year__)][i_mon-1]*day____s;}//将日转化为当年1日out_second += (start_day___-1)*day____s;///以下时间基于 xxxx-01-01T00:00:00out_day___ = out_second / (long long)day____s;out_second = out_second % day____s;out_hour__ = out_second / hour___s;out_second = out_second % hour___s;out_minute = out_second / minute_s;out_second = out_second % minute_s;while(out_day___ >= year___d[IfLeapYear(out_year__)]) ///$$$$$$$$$$$$$$$${out_day___ -= year___d[IfLeapYear(out_year__)];out_year__++;}while(out_day___ >= month__d[IfLeapYear(out_year__)][out_month_-1]){out_day___ -= month__d[IfLeapYear(out_year__)][out_month_-1];out_month_++;}//cout<<out_year__<<"-"<<out_month_<<"-"<<out_day___<<"T"<<out_hour__<<":"<<out_minute<<":"<<out_second<<endl;char* out_C = (char*)malloc(sizeof(char)*1000);sprintf(out_C, "%04d-%02d-%02d %02d:%02d:%02d", out_year__, out_month_, out_day___, out_hour__, out_minute, out_second);//cout<<"****************"<<out_C<<endl;return out_C;
}
-
C++实现删除txt文件中的指定内容
-
获取子字符串
tempStr = input_group_name.substr(iInLen+1,input_group_name.length()-iInLen-1);
- C++复制剪切删除文件
- C++打开文件夹
- C++将变量名转换为字符串
- 只使用位运算实现整数加减乘除
- C++按照空格分割字符串
- C++使用空格或者特定字符 分割字符串string
- C++获取文件夹下所有文件的路径
- 取整
ceil();//向上舍入为最接近的整数
floor();//向下舍入为最接近的整数
round();//对浮点数进行四舍五入
总结
无