Help with Logic

I have a line like this

word file1 3 file2 8 file1 5 file2 11 file3 9
Can anybody give me a logic to give the output like this
word 3 //because it is present in 3 files

Ex 2
word2 file4 5 file5 8 file4 10 file6 3 file7 5 file7 12
word2 4

I am not asking the code.But I am just asking with the logic.I have been thinking of this for the past 3 days but couldnt get a logic for implementing this.

Please help me.Thanks in advance.

What do you mean by "I've got a line"? If you mean you've cout'ed all of that, then there probably isn't a way for any system to just read that and rearrange it.

However, it could work if you had something like an array.
That is a line in file.I read line by line from a file.
I need to think about this one. Can you give me a deeper explanation as to what you want done with the line?
Topic archived. No new replies allowed.