开发者

program that takes a string as input from user from command line and printing only list of unique characters [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

How to parse the string's individual character for eg " =-. lajadsfdddll ooo532333 ksfoiww0etu - " /.> W开发者_C百科#H^*!@#~ nsa@". and add each individual character into hash and then count as ohw many times each character has apeared and the only unique character.


As it sounds very much like a homework question, I'll try pushing you in the right direction. Hopefully you know how to take in a line of user input. In this case, your very general algorithm will look like this:

1. Take the input
2. Parse the input into individual characters - Think about Perl built in methods
3. Add characters to the Hash and count. 
4. Iterate through the Hash and print the relevant data.

Character counting is a pretty common problem in a variety of languages, so utilizing Google will be your friend. Also consider that Hashes associate a Key with some value, and only stores unique keys, but it can store any value type.

Additionally, the Perl Cookbook has a recipe on the free online book that discusses how to read individual characters of a string, and this tutorial can be found in a variety different sites.

Long story short, there are plenty of resources out there to answer this problem, and you'll learn more if you go out and find them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜