If anyone knows the answer

Get help using and writing Nisus Writer Pro macros.
Post Reply
gopalsd
Posts: 1
Joined: 2008-02-12 01:40:52

If anyone knows the answer

Post by gopalsd » 2008-02-12 01:50:58

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.

User avatar
martin
Official Nisus Person
Posts: 4261
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin » 2008-02-12 11:42:24

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.

Post Reply