How would I code this problem in C?
Write software that reads as many as 1000 integer ideals, and is important the regularity.
Output will need to look similar to this:
Worth Freq
ONE 3
THREE 5
etc..
We can scan values into an array and art print stuff good, im a bit confused regarding how I in making the consistency table job.I appeared to be thinking any for loop and also a second array plus some pointers, but I have no idea…
Any help will be much appreciated!!!
Thank you,
James
if you do not know the product range of your own ints then you could use an array to help keep the beliefs.
for each value in your input facts (values) scan over the frequency table
if found rise the count
if not found add the value to that table and bump up along the kitchen table.
NOTE the actual frequency count is definately sorted
when you need sorted that you can do it following frequencys are usually found
it could be either with value obtain or
consistency order
untested code follows:
int maxnum=0; /* variety of unique values found so far */
int nums10002;
int j.my spouse and i;
int values1000;
…
initialize attitudes here
….
int num_ints……// the amount of ints for you to check
num_ints =…a number of value
for(i=0; i<num_ints; i++)
for(j=0; j<maxnum; j++) /* when this starts off maxnum is actually 0 so this is certainly skipped */
if( valuesi== numsi0)
numsi1++;
crack;
if(j==maxnum) /* NOT NECESSARILY FOUND */
numsmaxnum0=valuesi; /* add the fresh value into the list */
numsmaxnum1=1; /* include the count to the list */
maxnum++; /* increase the checklist */
If you know the range with the numbers then dimension a spectrum with which range.For example, if the actual numbers may be 0 by 21 then
int num22;
Then while you read the actual numbers, say a freshly read range is saved in temp:
int temp = 16;
numtemp++;
In order that numk can contain the actual count associated with he value k.
http://www.cs.utah.edu/germain/PPS/Topics/for_loops.html
http://techforum4u.com/showthread.php/2203-Program-to-find-the-sum-of-odd-and-even-numbers
go to be able to
http://sourcecode4u.com/ to get your answer!!
there are many c plans with end result!!!
Leave a Reply
You must be logged in to post a comment.