Results 1 to 4 of 4
Thread: C++
Hybrid View
-
15th March 2011 18:10 #1
C++
, .
, . , . , Ap double, .Code://===================== ZeroReverse // interpolaciq na Lagrange #include <iostream> using namespace std; //===================== int main() { long double Ap; // promenliva za stoinosta koqto 6te priblijavame (x) int s; // razmer na masivite - broi na to4ki double x[s]; //masiv za stoinostite na x double y[s]; // masiv za stoinostite na y int p=s-1; // stepenta na polinoma cout<<"Input value for x "; cin>>Ap; cout<<"Input number of elements "; cin>>s; //podavane na stoinostite za x for(int i=0; i<s; i++) { cout<<"Input value for x["<<i<<"] "; cin>>x[i]; } //podavane na stoinostite za y for(int i=0; i<s; i++) { cout<<"Input values for y["<<i<<"] "; cin>>y[i]; } double mn=1; // double del=1; // double sum=0; // for(int i=0; i<s; i++) { //cikul za presmqtane na mnojitelite ot tipa (x-x1) etc. v subiraemite for(int q=0; q<=p; q++) { int cy=i; // promenliva otbelqzva6ta indeksa na teku6tiq y if(q==cy) continue; // 6te me vru6ta na gorniq cikul ako indeksite na y i x suvpadnat double mn1=(Ap-x[q]); // iz4islqva poredniq mnojitel ot 4islitelq double del1=(x[i]-x[q]); // iz4islqva poredniq mnojitel ot delitelq del=del*del1; // iz4islqva znamenatelq mn=mn*mn1; //iz4islqva 4islitelq } // sled kraq na toq cikul trqbva da imam 4islitelq i znamenatelq za suotvetnoto subiraemo (opredeleno ot po predhodniq cikul) sum=sum+y[i]*(mn/del); } cout<<sum; system("pause"); return EXIT_SUCCESS; }
.Code://===================== ZeroReverse // interpolaciq na Lagrange #include <iostream> using namespace std; //===================== int main() { long double Ap; // promenliva za stoinosta koqto 6te priblijavame (x) int s; // razmer na masivite - broi na to4ki double x[s]; //masiv za stoinostite na x double y[s]; // masiv za stoinostite na y int p=s-1; // stepenta na polinoma cout<<"Input value for x "; cin>>Ap; cout<<"Input number of elements "; cin>>s; //podavane na stoinostite za x for(int i=0; i<s; i++) { cout<<"Input value for x["<<i<<"] "; cin>>x[i]; } //podavane na stoinostite za y for(int i=0; i<s; i++) { cout<<"Input values for y["<<i<<"] "; cin>>y[i]; } double temp=1; long double sum=0; for(int i=0; i<s; i++) { //cikul za presmqtane na mnojitelite ot tipa (x-x1) etc. v subiraemite for(int q=0; q<=p; q++) { int cy=i; // promenliva otbelqzva6ta indeksa na teku6tiq y if(q==cy) continue; // 6te me vru6ta na gorniq cikul ako indeksite na y i x suvpadnat temp=temp*((Ap-x[q])/(x[i]-x[q])); } sum=sum+y[i]*temp; } cout<<sum; system("pause"); return EXIT_SUCCESS; }
Config: Ryzen 3700x / Gigabyte x570 Gaming X / RX480 Strix 1400@2250 / 2x8gb Corsair Vengeance / Seagate Barracuda 1Tb + 256gb OCZ Trion / SuperFlower Leadex II Gold 750w / BeQuiet B801 / LG 23MA53 + Philips 170c / Logitech G502 / CM QuickFire TK
Acer Predator G9-593 I7 7700HQ + GTX1070
-
15th March 2011 18:57 #2
, x[] y[] - .. s, , -.
, s, .
-, 20 .Code:double x[20]; double y[20];
, . .
"640K ught to be enough for anybody" - Bill Gates, 1981
::Machine specs::Fract::AGG::::Baileys::blog::YouTube channel
-
15th March 2011 19:31 #3
, , s. , .
- s double mn=1; // double del=1; //, temp . .
, .
- .
!Config: Ryzen 3700x / Gigabyte x570 Gaming X / RX480 Strix 1400@2250 / 2x8gb Corsair Vengeance / Seagate Barracuda 1Tb + 256gb OCZ Trion / SuperFlower Leadex II Gold 750w / BeQuiet B801 / LG 23MA53 + Philips 170c / Logitech G502 / CM QuickFire TK
Acer Predator G9-593 I7 7700HQ + GTX1070
-
15th March 2011 21:39 #4
new delete:
- , .Code:... s ... double *x = new double[s]; double *y = new double[s]; ... x y ... delete [] x; delete [] y;
Internet - it doesn't make you stupid, it just makes your stupidity more accessible to others




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in