Andrei Ursan wrote:
> [code]
> #include <iostream.h>
> #include <conio.h>
> 
> void r_string(int n, int v[])
> {
> int i;
> 
> for(i=0;i<n;i++)
>  {
>  cout<<"v["<<i<<"]=";
>  cin>>v[i];
>  }
> 
> }
> 
> void p_string(int n, int v[])
> {
> int i;
> cout<<"\nThe string is : ";
> 
> for(i=0;i<n;i++)
>     cout<<v[i]<<"  ";
> 
> }
> 
> float avarage_string(int n, int v[])
> {
> int i,s=0;
> float av;
> for(i=0;i<n;i++)
> s+=v[i];
> 
> av=(float)s/n;
> 
> return av;
> }
> 
> void main()
> {
> clrscr();
> 
> int no, a[20];
> cout<<" no = ";
> cin>>no;
> r_string(no,a);
> p_string(no,a);
> 
> cout<<"String avarage is : "<<avarage_string(no,a);
> 
> getch();
> }
> [/code]
> 
> Strings value are read from the keyboard, and i need a getch and clrscr
> method.
> And how can I export the ruby code into *.exe ?
> 
> Can somebody translate this into ruby ? I need it fast...
> 

Well, since you ask _that_ nicely...
This may get you started

print "number of entries: "
no = gets.to_i

a = []
no.times do |i|
   print "enter item nr. #{i}: "
   a << gets.to_i
end

p a

puts a.inject(0){|s, x| s + x}.to_f / a.size unless a.empty?


It's rather quick-and-dirty, but then, so was your C++ code.

HTH,

Michael

-- 
Michael Ulm
R&D Team
ISIS Information Systems Austria
tel: +43 2236 27551-542, fax: +43 2236 21081
e-mail: michael.ulm / isis-papyrus.com
Visit our Website: www.isis-papyrus.com

---------------------------------------------------------------
This e-mail is only intended for the recipient and not legally
binding. Unauthorised use, publication, reproduction or
disclosure of the content of this e-mail is not permitted.
This email has been checked for known viruses, but ISIS accepts
no responsibility for malicious or inappropriate content.
---------------------------------------------------------------