Depends on the number of skills. If it is small, I would use prime numbers. More preciesly:
Create table skills[n]
(where n is number of users). Fill it with 1
s. Then, if the user knows first skill (in this case C) multiply by first prime number (2), if he knows second skill multiply by second prime number, etc.
Then, if you want to find if user i
knows second skill (C++) , simply check if skills[i]%3==0
Example: Finding skill value: user 1 knows skill 1 (C) and skill 3 (Perl), what means his skill value is 1*2*5=10. User 2 knows skill 3, so his skill value is 1*5.
Finding all users that can use C,C++,Perl matching 2:
for(int i=0;i<n;i++){
int howMany=0;
if(skill[i]%2)==0)
howMany++;
if(skill[i]%5)==0)
howMany++;
if(skill[i]%7)==0)
howMany++;
if(howMany>=2)
addToResult(i);
}
Alternatively, you could create a 2d array, where column corresponds to person and row to skill. If value is set to 1 it means person knows how to use the skill, if it's set to 0, they don't. Then, simply add valus of all rows you need, and find proper user.
Example:
C 1 | 0 | 0 |
C++ 0 | 0 | 1 |
PERL 1 | 1 | 1 |
Lets find someone who knows C, Perl - We add all values from rows 1 and 3, we get
SUM 2 | 1 | 1 |
Only column 1 has value >=2, what means it's the only one that fulfills criteria. Now, let's try finding someone who uses C, C++ and PERL, matching 2
SUM 2 | 1 | 2
We know now that user 1 and user 3 have value of sum >=2, so they fulfill those criteria.