<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > VC下使用復(fù)數(shù)示例(建議使用“用法一”)

          VC下使用復(fù)數(shù)示例(建議使用“用法一”)

          作者: 時(shí)間:2011-07-05 來源:網(wǎng)絡(luò) 收藏
          一”)一#include math.h>#include complex>using namespace std;typedef complexdouble> Complex;int main(int argc, char* argv[]){Complex a,b,c;a = Complex::complex(1.,.2);		//賦初值printf(%f,%fn,real(a),imag(a));	//real()取實(shí)部,imag()取虛部b = Complex::complex(1.,.2);		//賦初值c = Complex::complex(1.,.2);		//賦初值a = b + c;printf(%f,%fn,real(a),imag(a));double k=2.0;	//數(shù)乘的時(shí)候數(shù)的類型一定要和
          實(shí)部和虛部的類型相同,此處為doublea = k * a;	//所有需要和運(yùn)算的實(shí)數(shù)都要定義為和實(shí)部虛部類型相同printf(%f,%fn,real(a),imag(a));return 0;}******************************************************************二#include math.h>#include complex>int main(int argc, char* argv[]){std::complexdouble> x,y,z;x = std::complexdouble> (1.,.02);printf(x = %f,j%fn,std::real(x),std::imag(x));y = std::complexdouble> (1.,.02);z = std::complexdouble> (1.,.02);x = y * z;printf(x = %f,j%fn,std::real(x),std::imag(x));return 0;}******************************************************************用法三#include math.h>int main(int argc, char* argv[]){_complex c_val1,c_val2,c_val3;c_val1.x = 1.;c_val1.y = .2;c_val2.x = 1.;c_val2.y = .2;c_val3.x = c_val1.x + c_val2.x;c_val3.y = c_val1.y + c_val2.y;printf(sum = %f,j%fn,c_val3.x,c_val3.y);return 0;}


          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();