标签:style blog http color for 2014 div log amp
struct topic_info_t { int topic_id; float topic_pr; }; float sim(const vector<topic_info_t>& query_info,const vector<topic_info_t>& adwords){ vector<topic_info_t>::iterator it1 = query_info.begin(); vector<topic_info_t>::iterator it2 = adwords.begin(); float sim = 0.0; for (; it1 != query_info.end() && it2 != adwords.end() ;){ if(it1->topic_id == it2->topic_id){ sim += it1->topic_pr*it2->topic_pr; it1++; it2++; } else if(it1->topic_id < it2->topic_id) it1++; else it2++; } return sim; } float max_sim(const vector<topic_info_t>& query_info, const vector<topic_info_t> adwords_topic_info[],int adwords_number){ if (NULL == adwords_topic_info || adwords_number <= 0) return 0.0; float maxSim = sim(query_info,adwords_topic_info[0]); int i = 1; while(i<adwords_number){ simI = sim(query_info,adwords_topic_info[i]); if(simI > maxSim) maxSim = simI; } return maxSim; }
标签:style blog http color for 2014 div log amp
原文地址:http://www.cnblogs.com/scofield0li/p/3935208.html