然后在主函數(shù)main里調(diào)用sum和mul函數(shù)求1到30累加和1到15累乘,最后把累加和累乘結(jié)果輸出你這是用什么方法啊,頭文件和主函數(shù)名都沒(méi)有啊
2 回答

鴻蒙傳說(shuō)
TA貢獻(xiàn)1865條經(jīng)驗(yàn) 獲得超7個(gè)贊
private int CountSum(int pintSum)
{
int intSum = 0;
for(int intIndex=1;intIndex <=pintSum;intIndex ++)
{
intSum = intSum + intIndex;
}
return intSum;
}
private long CountMul(int pintMul)
{
long intMul = 1;
for (int intIndex = 1; intIndex <= pintMul; intIndex++)
{
intMul = intMul * intIndex;
}
return intMul;
}
在主函數(shù)中調(diào)用時(shí):
CountSum(30);
CountMul(15);
- 2 回答
- 0 關(guān)注
- 175 瀏覽
添加回答
舉報(bào)
0/150
提交
取消