Reply to topic  [ 2 posts ] 
If anyone knows the answer 
Author Message

Joined: 2008-02-12 01:40:52
Posts: 1
Dear Friends,
If anyone knows the answer for below mentione query, pls post answer.


#!/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";


QUE: the median is the middle value if the numbers have been sorted in
ascending order (for even numbers of values it is your choice to pick
the first or second of the middle numbers.


2008-02-12 01:50:58
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
I'm afraid I don't see any question in the post you've made, so I can't answer it.

However, in general this perl code won't be useful in Pro because you can't prompt the user for numbers on standard input this way. When you run a perl macro the text selected in Pro is piped directly to STDIN. So if you're trying to adapt the macro for use in Pro, you should probably read STDIN without asking the user how many numbers there are.


2008-02-12 11:42:24
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software