#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("長方形的高度為:%d\n",?Height);
?printf("請輸入長度\n");
?scanf("%d",?&m_Long);
?printf("請輸入寬度\n");
?scanf("%d",?&m_Width);
?result?=?calculate(m_Long,?m_Width);
?printf("長方形的體積是:");
?printf("%d\n",?result);
?system("pause");
?return?0;
}
int?calculate(int?Long,?int?Width)
{
?int?result?=?Long*Width*Height;
?return?result;
}
//請問int?calculate(int?Long,?int?Width)與calculate(m_Long,?m_Width)有什么關(guān)系,為什么
???m_Long和Long可以互相賦值哪?
//
1 回答

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