-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRatingDistance.cpp
More file actions
51 lines (41 loc) · 938 Bytes
/
RatingDistance.cpp
File metadata and controls
51 lines (41 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <map>
#include <cmath>
#include "common.h"
using namespace std;
extern map<int, map<int, float>> ratings;
int main(int argc, char* argv[])
{
if(argc != 3)
{
cerr << "Format: RatingDistance [UserID1] [UserID2]" << endl;
return 1;
}
int userID1 = atoi(argv[1]);
int userID2 = atoi(argv[2]);
if(!isUserID(userID1))
{
cerr << "User 1 id out of bound." << endl;
return 1;
}
if (!isUserID(userID2))
{
cerr << "User 2 id out of bound." << endl;
return 1;
}
if(parser() == -1)
{
cerr << "Parsing error." << endl;
return 1;
}
float ratingDist = ratingDistance(userID1, userID2);
if(ratingDist == -1.0)
{
cout << "No common movies between users." << endl;
}
else
{
cout << "The rating distance is: " << ratingDist << endl;
}
return 0;
}