diff --git a/util.hpp b/util.hpp new file mode 100644 index 0000000..edb2734 --- /dev/null +++ b/util.hpp @@ -0,0 +1,218 @@ +/// Part of BigData Project. Included By Main.cpp . +/// This file should not be included by other files. + +/// 薪资空间,平均值 单位:元,月薪 +struct cash_pack +{ + int low,high; + + int ave() const {return (low+high)/2;} +}; + +/// 为map设计的比较算法 +bool operator < (const cash_pack& a,const cash_pack& b) +{ + if(a.low==b.low) + { + return a.high [ x30 ] 转换到 -> 元/月 , low=high + int c; + sscanf(ptr,"%d",&c); + pk.low=pk.high=c*30; + } + else + { + double dlow,dhigh; + sscanf(ptr,"%lf",&dlow); + sscanf(p+1,"%lf",&dhigh); + + /// 解析单位 + if(strstr(ptr,"千")!=nullptr||strstr(ptr,"k")!=nullptr||strstr(ptr,"K")!=nullptr) + { + dlow*=1000; + dhigh*=1000; + } + else if(strstr(ptr,"万")!=nullptr) + { + dlow*=10000; + dhigh*=10000; + } + else if(strstr(ptr,"元")!=nullptr) + { + + } + else + { + cout<<"strange: 单位错误"< ParseTag(const char* str) +{ + vector vec; + + char* s=(char*)str; + char* p=nullptr; + char buff[256]; + while(nullptr!= + (p=strstr(s,",")) + ) + { + memset(buff,0,256); + strncpy(buff,s,p-s); + vec.push_back(string(buff)); + s=p+1; + } + + int len=strlen(str); + if(s=0;--i) + { + if(str[i]==' '||str[i]=='\t'||str[i]=='\n'||str[i]=='\r') + { + continue; + } + else + { + R=i; + break; + } + } + if(R==-1) + { + /// All characters are [Space]/ + return ""; + } + + return str.substr(L,R-L+1); +}