From: "Darryl L. Pierce" Date: 2011-08-12T22:34:20+09:00 Subject: Re: A Corresponding between C++ AND Ruby --+xNpyl7Qekk2NvDX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 12, 2011 at 10:10:24PM +0900, amir a. wrote: > Hi > I am C++ programmer and in C++ I used some thing that I want > corresponding those things in Ruby. > please help me. >=20 > 1 - In C++ , I can write this program but in Ruby I can't: > int i,x; > int sum=3D0; > for( x=3D0 ; x <=3D 50 ; x++ ) { > cin >> i; > sum =3D sum + ( x + i ) ; > } > cout << sum; sum =3D 0 (0..50).each do value =3D gets value.chomp! sum +=3D value.to_i end puts sum > 2 - int a,b,c,d; > while( 1 ) { > cin >> a >> b >> c >>d ; > if( a < 0 || b < 0 ) > break; > cout << a << " " << b << " " << c << " " << d << endl; > } >=20 >=20 > thanks. Based on my above example (which is Ruby for the C++ programmer) the second should be easy for you to translate. --=20 Darryl L. Pierce http://mcpierce.multiply.com/ "What do you care what people think, Mr. Feynman?" --+xNpyl7Qekk2NvDX Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iEYEARECAAYFAk5FK9gACgkQtddqM0QFuLLZxwCfYm239bS4fXm2TIImUL9FZLXn 2VIAn2ttunG75JBRqH7OOYAwu2yX+ifk =4I+T -----END PGP SIGNATURE----- --+xNpyl7Qekk2NvDX--