?? cpolynomial.cpp
字號:
// CPolynomial.cpp : 定義控制臺應用程序的入口點。
//
#include "stdafx.h"
#include "CPolynomial.h"
int _tmain(int argc, _TCHAR* argv[])
{
string s;
do{
double dval = 0.0; int ival = 0;
int A_Num_items, B_Num_items;
vector<double> A_coefficients; vector<int> A_exponents;
vector<double> B_coefficients; vector<int> B_exponents;
cout<<"請輸入多項式A(x)的項數:"<<endl; cin>>A_Num_items;
cout<<"請輸入多項式A(x)的系數:"<<endl;
for(int i = 0; i < A_Num_items; i++){
cin>>dval;
A_coefficients.push_back(dval);
}
cout<<"請輸入多項式A(x)的指數:"<<endl;
for(int i = 0; i < A_Num_items; i++){
cin>>ival;
A_exponents.push_back(ival);
}
cout<<"請輸入多項式B(x)的項數:"<<endl; cin>>B_Num_items;
cout<<"請輸入多項式B(x)的系數:"<<endl;
for(int i = 0; i < B_Num_items; i++){
cin>>dval;
B_coefficients.push_back(dval);
}
cout<<"請輸入多項式B(x)的指數:"<<endl;
for(int i = 0; i < B_Num_items; i++){
cin>>ival;
B_exponents.push_back(ival);
}
CPolynomial pA(A_coefficients,A_exponents);
CPolynomial pB(B_coefficients,B_exponents);
CPolynomial pC;
cout<<"A(x) = "; cout << pA;
cout<<"B(x) = "; cout << pB;
cout<<"C(x) = A(x) + B(x)="; pC=pA + pB;
cout << pC;
double x;
cout <<"請輸入x的值:"; cin >> x;
cout << "A(" <<x<<") = " << pA(x) <<endl;
cout << "B(" <<x<<") = " << pB(x) <<endl;
cout << "C(" <<x<<") = " << pC(x) <<endl;
cin>>s;
} while(!(s == "exit"));
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -