Um... Are you sure you wanted this?
cin<<str[i];
Because I suspect you might have wanted this:
cin>>str[i];
Then...this is wrong:
a[str[i]]+=1;
Because regardless of the value of i, str[i] will be a character, which means that the space character will have a value of 32, and alphabetics a lot higher than that:
ASCII Table[
^] Since your array
a
only has 30 elements, no character you can type will result in a good index value into
a
Then there is the task: which even well and truly sorted out, that code isn't going to get close to - what you need to do is pass through your string, and identify each word start and end. You can then use that info to identify repeated words.
Try it on paper first, and when you have a good algorithm worked out, then you can try converting that to something a computer can understand. At the moment, you are rushing into code without properly thinking about the job first - and that just doesn't work well for anything more complex than "Hello World!"