From: Philip B. <ph...@bl...> - 2008-10-18 21:10:18
|
Hello there. I doubt that anyone on this list is going to write the program and send it to you... That would completely defeat the point of a "school assignment". However, I'll be glad to give you some pointers in the right direction so that you can then try to write the program based on that information. Let us assume that the number of possible characters is 128. If you think of a character in the string as a number (which is what it really is), a number from 0 to 127, an easy approach would be to create an array of ints to hold the number of times that the particular symbol has so far occured. To give a quick example... int my_array[128]; for int i=0; i<strlen(my_string); i++) my_array[my_string[i]]+=1; Then after you've looped through the entire string and incremented the corresponding array entry for each character that appears in the string, you can simply loop through it again and print out the results. Of course, you don't want to print out the ones that are 0. Hope this clears things up a bit. If not, feel free to ask again and I will try to explain it further. Regards Philip Bennefall ----- Original Message ----- From: 7amood joker To: dev...@li... Sent: Saturday, October 18, 2008 9:25 PM Subject: [Dev-C++] help hi....i really need help .....i have an assighnment in c++ ; the professor wants me to write a program which counts the symbols of a string.... here is the question.... A string is any combination of blanks, letters, digits and/or special characters. Write a C++ program to calculate and print the number of different symbols used in a given string. A blank space counts as one symbol. Input: Any string. The length is limited to 60 characters. For example: Enter a string: Mississipi Test data: #1. “Say good bye!” #2. “The world is round” Output: The number of different symbols. For example, the output for the string “Mississipi” is Number of symbols for the string “Mississippi” is: 4 THIS IS THE QUESTION ...SOO PLZZZZZ IF ANYYONE HERE KNOWS THE ANSWER JUST MSG IT TO ME .....AND HERE IS MY HOTMAIL ADDRES..U CAN SEND THE PROGRAM TO ME ..SOU...@HO.........THNXXX ------------------------------------------------------------------------------ Discover the new Windows Vista Learn more! ------------------------------------------------------------------------------ ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ ------------------------------------------------------------------------------ _______________________________________________ Dev-cpp-users mailing list Dev...@li... TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm https://lists.sourceforge.net/lists/listinfo/dev-cpp-users |