[理工] 资结 参数传递

楼主: lanlansaysay (Biu)   2020-07-05 19:59:30
https://i.imgur.com/Mgr5yR6.jpg
想请问这题为什么 i 跟 a[ i ] 都被改变了
b:integer 是代表宣告b为区域变量吗
想请问有宣告跟没宣告的差别
作者: cossetannie (paa)   2020-07-05 21:30:00
call by name是把名字替换 这题把a看作i ,b看成a[i]所以swap里会变成 temp=i ,i=a[i] ,a[i]=temp再把值带入得到 temp=3 ,i=a[3]=4, a[4]=3call by value跟call by name是不一样的传递方式然后b:integer只是告诉你宣告一个int变量而已
楼主: lanlansaysay (Biu)   2020-07-06 20:02:00
了解了 感谢楼上

Links booklink

Contact Us: admin [ a t ] ucptt.com