当前位置: 首页>>代码示例>>C++>>正文


C++ Movie::GetID方法代码示例

本文整理汇总了C++中Movie::GetID方法的典型用法代码示例。如果您正苦于以下问题:C++ Movie::GetID方法的具体用法?C++ Movie::GetID怎么用?C++ Movie::GetID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Movie的用法示例。


在下文中一共展示了Movie::GetID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: strcpy

Movie::Movie(const Movie &cpy):name(cpy.GetName()) {
    movieID = cpy.GetID();
    language = new char[strlen(cpy.GetLanguage())+1];
    strcpy(language, cpy.GetLanguage());
    for (register int i = 0; i < 8; i++) {
        const int *temp = cpy.GetRelDate();
        relDate[i] = temp[i];
    }
    category = cpy.GetCategory();
    inCinemas = cpy.GetCinemaList();
}
开发者ID:CodePanpan,项目名称:BookMyShow,代码行数:11,代码来源:Movie.cpp

示例2: main

int main(int argc, char ** argv)
{
	if (argc != 3)
	{
		cerr << "Usage: " << argv[0] << " personIndex recNum\n";
		return 1;
	}

	ifstream oFileIn;
	string strLine;

	///load movie info
	oFileIn.open(g_pMovieData, ios::in);
	Movie oMovie;
	while (getline(oFileIn, strLine))
	{
		Parser::ParseMovie(strLine, oMovie);
		g_mapMovieInfo[oMovie.GetID()] = oMovie;
	}
	oFileIn.clear();
	oFileIn.close();

	///load user info
	oFileIn.open(g_pUserData, ios::in);
	User oUser;
	while (getline(oFileIn, strLine))
	{
		Parser::ParseUser(strLine, oUser);
		g_mapUserInfo[oUser.GetID()] = oUser;
	}
	oFileIn.clear();
	oFileIn.close();

	///load rating
	oFileIn.open(g_pRatingData, ios::in);
	Rating oRating;
	while (getline(oFileIn, strLine))
	{
		Parser::ParseRating(strLine, oRating);
		g_mapRatingInfo[oRating.GetUserID()][oRating.GetMovieID()] = oRating;
	}
	oFileIn.close();

	size_t unMaxUserNum = g_mapUserInfo.rbegin()->first;
	size_t unMaxMovieNum = g_mapMovieInfo.rbegin()->first;
	///allocate memory
	g_szRatings = new double*[unMaxUserNum];	
	for (size_t unIdx = 0; unIdx < unMaxUserNum; ++ unIdx)
	{
		g_szRatings[unIdx] = new double[unMaxMovieNum];
		::memset(g_szRatings[unIdx], 0, sizeof(double)*unMaxMovieNum);
	}

	///get critics
	map<int, User>::iterator oItUser = g_mapUserInfo.begin();
	while (oItUser != g_mapUserInfo.end())
	{
		map<int, Rating>::iterator oItRating = g_mapRatingInfo[oItUser->first].begin();
		while (oItRating != g_mapRatingInfo[oItUser->first].end())
		{
			g_szRatings[oItUser->first - 1][oItRating->first - 1] = oItRating->second.GetRate();
			++ oItRating;
		}
		++ oItUser;
	}

	int nPersonIndex = ::atoi(argv[1]) - 1;
	int nRecNum = ::atoi(argv[2]);
	int * pRecItems = new int[nRecNum];
	double * pRecScores = new double[nRecNum];

	///Euclidean
	GetRecommendation(const_cast<const double **>(g_szRatings), unMaxUserNum, 
		unMaxMovieNum, nPersonIndex, GetEuclideanScore, nRecNum, pRecItems, pRecScores);
	cout << "---------------------Euclidean Recommendation: \n";
	for (int nIdx = 0; nIdx < nRecNum; ++ nIdx)
	{
		cout << nIdx << "\t" << pRecScores[nIdx] << "\t" 
			<< g_mapMovieInfo[pRecItems[nIdx]].GetTitle() << endl;
	}

	///Pearson
	GetRecommendation(const_cast<const double **>(g_szRatings), unMaxUserNum, 
		unMaxMovieNum, nPersonIndex, GetPearsonScore, nRecNum, pRecItems, pRecScores);
	cout << "\n---------------------Pearson Recommendation: \n";
	for (int nIdx = 0; nIdx < nRecNum; ++ nIdx)
	{
		cout << nIdx << "\t" << pRecScores[nIdx] << "\t" 
			<< g_mapMovieInfo[pRecItems[nIdx]].GetTitle() << endl;
	}

	///Tanimoto
	GetRecommendation(const_cast<const double **>(g_szRatings), unMaxUserNum, 
		unMaxMovieNum, nPersonIndex, GetTanimotoScore, nRecNum, pRecItems, pRecScores);
	cout << "\n---------------------Tanimoto Recommendation: \n";
	for (int nIdx = 0; nIdx < nRecNum; ++ nIdx)
	{
		cout << nIdx << "\t" << pRecScores[nIdx] << "\t" 
			<< g_mapMovieInfo[pRecItems[nIdx]].GetTitle() << endl;
	}
//.........这里部分代码省略.........
开发者ID:EssLi,项目名称:xiao5geproject,代码行数:101,代码来源:MakeRecommendations.cpp


注:本文中的Movie::GetID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。