p******g 发帖数: 1 | | g******t 发帖数: 11249 | 2 做科研不就是编程么
对于dry lab
【在 p******g 的大作中提到】
| d********m 发帖数: 3662 | | g**********y 发帖数: 423 | 4 千老干的活是这样的:
struct TIME
{
int seconds;
int minutes;
int hours;
};
void computeTimeDifference(struct TIME t1, struct TIME t2, struct TIME *
difference){
if(t2.seconds > t1.seconds)
{
--t1.minutes;
t1.seconds += 60;
}
difference->seconds = t1.seconds - t2.seconds;
if(t2.minutes > t1.minutes)
{
--t1.hours;
t1.minutes += 60;
}
difference->minutes = t1.minutes-t2.minutes;
difference->hours = t1.hours-t2.hours;
}
static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void
*userp)
{
((std::string*)userp)->append((char*)contents, size * nmemb);
return size * nmemb;
}
bool is_file_exist(std::string fileName)
{
std::ifstream infile(fileName);
return infile.good();
}
std::string replace(std::string& str, const std::string& from, const std::
string& to) {
size_t start_pos = str.find(from);
if(start_pos == std::string::npos)
return false;
return str.replace(start_pos, from.length(), to);
} | C**********e 发帖数: 23303 | 5 不错
钱老工作的精华在最后一个函数
【在 g**********y 的大作中提到】 : 千老干的活是这样的: : struct TIME : { : int seconds; : int minutes; : int hours; : }; : void computeTimeDifference(struct TIME t1, struct TIME t2, struct TIME * : difference){ : if(t2.seconds > t1.seconds)
|
|