//Example1-2:計算太陽和地球間的萬有引力<br /> #include<iostream.h><br /> double grav (double m1, double m2, double distance)<br /> ﹛<br /> double g, G=6.67259E-11;<br /> g=G*m1*m2/(distance*distance);<br /> return g<br /> ﹜<br /> void main ()<br /> ﹛<br /> double g, Msum=7.987E30,Mearth=5.975E24;<br /> g=grav(Msun, Mearth, 1.495E11);<br /> cout<<"The gravitation between sun and earth is"<<g<<"N."<<end|;<br /> ﹜