| CodeGuru Home | VC++ / MFC / C++ | .NET / C# | Visual Basic | Newsletters | VB Forums | Developer.com |
|
|||||||
| Visual C++ Programming Ask questions about Windows programming with Visual C++ and help others by answering their questions. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Stuck on a programming assignment
I am completely confused at how to go about putting together a code for the following:
I must accept a string of up to 256 characters from the user, and display the following information about the string: -The count, frequency, and probability of each character that appears in the string in decreasing order -Compute the Shannon Entropy of the string in bits. Thank you for taking the time to read this post, I greatly appreciate any and all help I can get. |
|
#2
|
||||
|
||||
|
Re: Stuck on a programming assignment
What code do you have so far?
__________________
Arjay Need a little help with Win32 thread synchronization? Check out the following CG articles and posts: Sharing a thread safe std::queue between threads w/progress bar updating Simple Thread: Part I Simple Thread: Part II Win32 Thread Synchronization, Part I: Overview Win32 Thread Synchronization, Part 2: Helper Classes www.iridyn.com
|
|
#3
|
|||
|
|||
|
Re: Stuck on a programming assignment
Absolutely nothing. I don't know even know where to start.
|
|
#4
|
|||
|
|||
|
Re: Stuck on a programming assignment
So what are we supposed to do to help you?
Start here: Code:
int main()
{
// fill this in
}
Paul McKenzie |
|
#5
|
||||
|
||||
|
Re: Stuck on a programming assignment
Start with programming up a simple console app where you get input from the user.
Create the main function and prompt the user for the input. Once you have that, post your code.
__________________
Arjay Need a little help with Win32 thread synchronization? Check out the following CG articles and posts: Sharing a thread safe std::queue between threads w/progress bar updating Simple Thread: Part I Simple Thread: Part II Win32 Thread Synchronization, Part I: Overview Win32 Thread Synchronization, Part 2: Helper Classes www.iridyn.com
|
|
#6
|
|||
|
|||
|
Re: Stuck on a programming assignment
Please don't get me wrong, I don't expect anyone to do the come up with a code for me. I'm just lost as far as how to calculate the count, frequency, and probability of a string of 256 characters. If anyone could at least show/link me some examples of this type of code. This is my first C programming class and I'm having trouble understanding it. This must sound silly to you professionals, but here is as far as I've gotten (probably totally off but I'm willing to work it 'til I've got it down):
#include<stdio.h> #include<stdlib.h> #include<math.h> #include<time.h> int main() { int count int frequency int probablity printf("Enter Character String (max 256): "); scanf("%d, &count&frequency&probability); return 0; } Long story short, i need a code to generate the count, frequency, probability, of each character that appears in the string Last edited by CNovice; November 9th, 2009 at 03:41 PM. |
|
#7
|
|||
|
|||
|
Re: Stuck on a programming assignment
Quote:
If you do not understand the above, please point to what you don't understand. You must have the fundamentals first (an array, loops, etc.) before doing anything else. Programming requires knowledge being built up from a base -- you can't just start from nowhere and all of a sudden, start coding an assignment. Regards, Paul McKenzie |
|
#8
|
|||
|
|||
|
Re: Stuck on a programming assignment
I'm not sure why they think that count, frequency, and probability are three different things. Count and probability are certainly different, but frequency could be the same as either of them depending on how you define it.
|
|
#9
|
|||
|
|||
|
Re: Stuck on a programming assignment
Thank you all for you input. This subject is very hard to understand. Maybe my brain isn't built for computer science after all.
|
![]() |
| Bookmarks |
| Tags |
| c programming , c++ , code , shannon entropy , visual studio |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|