#include<stdio.h>
#define?Height?10
#include<iostream>
int?calculate(int?Long,?int?Width);
int?main()
{
?int?m_Long;
?int?m_Width;
?int?result;
?printf("長(zhǎng)方形的高度為:%d\n",?Height);
?printf("請(qǐng)輸入長(zhǎng)度\n");
?scanf("%d",?&m_Long);
?printf("請(qǐng)輸入寬度\n");
?scanf("%d",?&m_Width);
?result?=?calculate(m_Long,?m_Width);
?printf("長(zhǎng)方形的體積是:");
?printf("%d\n",?result);
?system("pause");
?return?0;
}
int?calculate(int?Long,?int?Width)
{
?int?result?=?Long*Width*Height;
?return?result;
}
//請(qǐng)問(wèn)int?calculate(int?Long,?int?Width)與calculate(m_Long,?m_Width)有什么關(guān)系,為什么
???m_Long和Long可以互相賦值哪?
//
1 回答

guozhchun
TA貢獻(xiàn)103條經(jīng)驗(yàn) 獲得超76個(gè)贊
第4行代碼是calculate函數(shù)的聲明,第19行代碼是calculate函數(shù)的調(diào)用,第26~30行是calculate函數(shù)的定義。
第19行調(diào)用calculate函數(shù)時(shí),會(huì)把實(shí)參(這里就是m_Long, m_width)的值賦給形參(這里就是第26行的Long, Width)。而形參的值是不會(huì)賦值給實(shí)參的。也就是說(shuō)m_Long可以賦值給Long,而Long不能賦值給m_Long
- 1 回答
- 0 關(guān)注
- 1731 瀏覽
添加回答
舉報(bào)
0/150
提交
取消