課程
/后端開發
/C++
/C++遠征之起航篇
從鍵盤輸入5個數,求五個數的平方,并輸出。
要求:
1.使用cin cout輸入輸出
2.編寫求平方的函數 函數原型為int pow(x)
3.調用函數求得輸入的5個數的平方
2016-11-26
源自:C++遠征之起航篇 5-1
正在回答
#include <iostream>
using namespace std;
int pow(int a)
{
a=a*a;
? ? return a;
}
int main()
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
cout<<pow(a)<<endl<<pow(b)<<endl<<pow(c)<<endl<<pow(d)<<endl<<pow(e)<<endl;
system("pause");
return 0;
舉報
C++亮點盡在其中,本課程是在C語言基礎上的一個延伸,得以升華
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-11-26
#include <iostream>
using namespace std;
int pow(int a)
{
a=a*a;
? ? return a;
}
int main()
{
int a,b,c,d,e;
cin>>a>>b>>c>>d>>e;
cout<<pow(a)<<endl<<pow(b)<<endl<<pow(c)<<endl<<pow(d)<<endl<<pow(e)<<endl;
system("pause");
return 0;
}