-
November 8th, 2009, 10:15 PM
#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.
-
November 8th, 2009, 10:26 PM
#2
Re: Stuck on a programming assignment
What code do you have so far?
-
November 8th, 2009, 11:44 PM
#3
Re: Stuck on a programming assignment
Absolutely nothing. I don't know even know where to start.
-
November 8th, 2009, 11:53 PM
#4
Re: Stuck on a programming assignment
Originally Posted by CNovice
Absolutely nothing. I don't know even know where to start.
So what are we supposed to do to help you?
Start here:
Code:
int main()
{
// fill this in
}
Regards,
Paul McKenzie
-
November 8th, 2009, 11:54 PM
#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.
-
November 9th, 2009, 03:10 PM
#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.
-
November 9th, 2009, 04:28 PM
#7
Re: Stuck on a programming assignment
Originally Posted by CNovice
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.
You have an array of 26 integers, all elements of the array are set to 0. Then you loop through the string, and for every character i, you increment the count in array[i]. Then after the loop is finished, you have an array of the count of each character -- part 1 is done.
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
-
November 9th, 2009, 05:02 PM
#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.
-
November 9th, 2009, 07:21 PM
#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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|