Dear Friends,
Anyone pls reolve mentioned problem.............
QUES: the median is the middle value if the numbers have been sorted inCode:#!/usr/bin/perl @data=N; $sum=0; print"enter the required No. of numbers to be inputed : f"; $N=<STDIN>; print"enter the number"; for($i=0;$i<$N;$i+=1) {$data[$i]=<STDIN>; # chomp $data[$i]; $sum=$sum + $data[$i];} # for($j=0;$j=$data[$i];$j+=1) print"the entered numbers are",@data,"\n"; print"sum of the number:",$sum,"\n"; print"Average value the numbers:",$sum/$N,"\n"; @sorting=sort(@data); $lengt=@data; for ($j=0;$j < $lengt;$j++) {# print $sorting[$j],"\n"; } $X= (@sorting[($j-1)/2]+ @sorting[$j/2])/2; print"the median is :$X";
ascending order (for even numbers of values it is your choice to pick
the first or second of the middle numbers.
Last edited by v0id; 02-12-2008 at 05:01 AM.
Remember to use code-tags next time you're posting some code.
so what's your problem?
Visit My Google Group Here: Web Development Innovation
I'd still like to know what your question is. You posted your code, along with a comment, but never asked a question.
Visit My Google Group Here: Web Development Innovation
The question is: will somone do my school/class assignment for me?![]()
Visit My Google Group Here: Web Development Innovation
Judging by his code he is not going to get a good grade/mark. Hopefully that is not what they are teaching in school/class these days, that be some nasty looking perl code.
lol, I agree....I really like the misspelling of the word "length".
Visit My Google Group Here: Web Development Innovation
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks