锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
int main()
{ //int綾誨瀷鐨勫璞?BR> int val=2;
int pow=10;
cout<<val<<"raised to the power of"
<<pow<<"\t";
int res=1;
//鐢ㄤ簬淇濆瓨緇撴灉錛?BR> //寰幆璁$畻res鐩磋嚦cnt澶т簬pow
for(int cnt=1; cnt<=pow;++cnt)
res=res*val;
cout<<res<<endl;
}
榪欐牱鍋氱殑紼嬪簭鍙Щ妞嶆у樊錛岀О闇瑕佹嬁鍒板埆鐨勫湴鏂瑰幓浣跨敤瑕佺粡榪囪緝澶т慨鏀廣傛晠鑰冭檻淇敼濡備笅錛?BR> 棣栧厛鏂板緩涓涓嚱鏁板涓?BR> int pow(int val,int exp)
{ int res=1;//璁懼畾淇濆瓨緇撴灉
for(int cnt=1;cnt<=exp;++cnt)
res=res*val;
return res;
}
鍏舵鍐欎竴涓富紼嬪簭
#include<iostream>
extern int pow(int,int)
int main()
{
int val=2;
int pow=10;
cout<<val<<"raised to the power of "<<pow<<":\f"
cout<<pow(val,pow)<<endl;
}
鍚庣粡鍙戠幇涓婅竟綰㈣壊鐨勬爣璇嗙殑鍙ュ瓙錛屾湁閿欒搴旀敼涓?BR>for(int cnt=1;exp>=cnt;--exp)
2006騫?鏈?鏃?:48:05
]]>