#include <iostream>
#include <vector>
#include <string>
std::string likes(const std::vector<std::string> &names)
{
if (names.size() == 0)
return "no one likes this";
else if (names.size() == 1)
return names[0] + " likes this";
else if (names.size() == 2)
return names[0] + " and " + names[1] + " like this";
else if (names.size() == 3)
return names[0] + ", " + names[1] + " and " + names[2] + " like this";
else if(names.size() > 3)
return names[0] + ", " + names[1] + " and " + (names.size()-2) + " others like this"; /*this line isn't working, i guess the problem is in names.size() */
The last line is causing my application to not run, i have tried every possible way i know to solve this but nothing really helped, can you please help?