Avoid system
It's not recommended to use system
, ever,
as it can easily lead to problems such as privilege escalation.
It's hard to defend using system
, so don't.
Don't using namespace std;
This is considered a bad practice. This is considered a bad practice.
Always close resources
In the getUsers
function, myfile
is probably not always closed,
because the only code snippet that closes it is buried deep within nested conditionals.
Reorganize the code to make sure the file always gets closed.
Naming
Capitalized names are commonly used for classes, not for variables.
The Count
variable stands out like that, it would be better to lowercase it.
Formatting
Do add empty lines between functions. Also consider adding some between statements inside functions, to visually emphasize blocks of code that are closely related.
It's recommended to use braces with all if/for/while
statements,
even when the body is a single line.
This is especially bad:
for(int i = 0 ; i < v.size() ; i++) v[i].points = 80.0/(40.0+ v[i].users), v[i].links = "<a href =\" http:://www.spoj.com/problems/" + v[i].name +"\"> " + v[i].name +" "+ to_string(v[i].points) +"</a> <br>";
It's very easy to make an oversight and break this code, with that comma at the end of the second line. Just use braces:
for(int i = 0 ; i < v.size() ; i++) {
v[i].points = 80.0/(40.0+ v[i].users);
v[i].links = "<a href =\" http:://www.spoj.com/problems/" + v[i].name +"\"> " + v[i].name +" "+ to_string(v[i].points) +"</a> <br>";
}
Avoid system
It's not recommended to use system
, ever,
as it can easily lead to problems such as privilege escalation.
It's hard to defend using system
, so don't.
Don't using namespace std;
This is considered a bad practice.
Always close resources
In the getUsers
function, myfile
is probably not always closed,
because the only code snippet that closes it is buried deep within nested conditionals.
Reorganize the code to make sure the file always gets closed.
Naming
Capitalized names are commonly used for classes, not for variables.
The Count
variable stands out like that, it would be better to lowercase it.
Formatting
Do add empty lines between functions. Also consider adding some between statements inside functions, to visually emphasize blocks of code that are closely related.
It's recommended to use braces with all if/for/while
statements,
even when the body is a single line.
This is especially bad:
for(int i = 0 ; i < v.size() ; i++) v[i].points = 80.0/(40.0+ v[i].users), v[i].links = "<a href =\" http:://www.spoj.com/problems/" + v[i].name +"\"> " + v[i].name +" "+ to_string(v[i].points) +"</a> <br>";
It's very easy to make an oversight and break this code, with that comma at the end of the second line. Just use braces:
for(int i = 0 ; i < v.size() ; i++) {
v[i].points = 80.0/(40.0+ v[i].users);
v[i].links = "<a href =\" http:://www.spoj.com/problems/" + v[i].name +"\"> " + v[i].name +" "+ to_string(v[i].points) +"</a> <br>";
}
Avoid system
It's not recommended to use system
, ever,
as it can easily lead to problems such as privilege escalation.
It's hard to defend using system
, so don't.
Don't using namespace std;
This is considered a bad practice.
Always close resources
In the getUsers
function, myfile
is probably not always closed,
because the only code snippet that closes it is buried deep within nested conditionals.
Reorganize the code to make sure the file always gets closed.
Naming
Capitalized names are commonly used for classes, not for variables.
The Count
variable stands out like that, it would be better to lowercase it.
Formatting
Do add empty lines between functions. Also consider adding some between statements inside functions, to visually emphasize blocks of code that are closely related.
It's recommended to use braces with all if/for/while
statements,
even when the body is a single line.
This is especially bad:
for(int i = 0 ; i < v.size() ; i++) v[i].points = 80.0/(40.0+ v[i].users), v[i].links = "<a href =\" http:://www.spoj.com/problems/" + v[i].name +"\"> " + v[i].name +" "+ to_string(v[i].points) +"</a> <br>";
It's very easy to make an oversight and break this code, with that comma at the end of the second line. Just use braces:
for(int i = 0 ; i < v.size() ; i++) {
v[i].points = 80.0/(40.0+ v[i].users);
v[i].links = "<a href =\" http:://www.spoj.com/problems/" + v[i].name +"\"> " + v[i].name +" "+ to_string(v[i].points) +"</a> <br>";
}
Avoid system
It's not recommended to use system
, ever,
as it can easily lead to problems such as privilege escalation.
It's hard to defend using system
, so don't.
Don't using namespace std;
This is considered a bad practice.
Always close resources
In the getUsers
function, myfile
is probably not always closed,
because the only code snippet that closes it is buried deep within nested conditionals.
Reorganize the code to make sure the file always gets closed.
Naming
Capitalized names are commonly used for classes, not for variables.
The Count
variable stands out like that, it would be better to lowercase it.
Formatting
Do add empty lines between functions. Also consider adding some between statements inside functions, to visually emphasize blocks of code that are closely related.
It's recommended to use braces with all if/for/while
statements,
even when the body is a single line.
This is especially bad:
for(int i = 0 ; i < v.size() ; i++) v[i].points = 80.0/(40.0+ v[i].users), v[i].links = "<a href =\" http:://www.spoj.com/problems/" + v[i].name +"\"> " + v[i].name +" "+ to_string(v[i].points) +"</a> <br>";
It's very easy to make an oversight and break this code, with that comma at the end of the second line. Just use braces:
for(int i = 0 ; i < v.size() ; i++) {
v[i].points = 80.0/(40.0+ v[i].users);
v[i].links = "<a href =\" http:://www.spoj.com/problems/" + v[i].name +"\"> " + v[i].name +" "+ to_string(v[i].points) +"</a> <br>";
}