Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include<iostream>
  2. #include<windows.h>
  3. #include<iomanip>
  4. #include <math.h>
  5. using namespace std;
  6.  
  7. double fi(double x);
  8. double Uxt (double x, double a, double t);
  9.  
  10. int main(){
  11. system("chcp 1251 > nul");
  12. double a, t, U;
  13. cout<<"Введите Коэффициент жесткости (a) и Момент времени (t)"<<endl;
  14. cin>>a>>t;
  15. cout<<"x="<<setw(15)<<"U="<<endl;
  16. for (double x=0; x<=10; x+=0.5)
  17. {
  18. U=Uxt(x,a,t);
  19. cout<<fixed<<x<<setw(15)<<U<<endl;
  20. }
  21. }
  22.  
  23.  
  24. double fi(double x){
  25. double f;
  26. if ((x>=3.14) && (x<=6.28))
  27. f=-sin(x);
  28. else f=0;
  29. return f;
  30. }
  31.  
  32.  
  33. double Uxt(double x, double a, double t){
  34. double U;
  35. if (x-a*t<=0)
  36. U=(fi(x-a*t)+fi(x+a*t))/2;
  37. else U=(-fi(a*t-x)+fi(x+a*t))/2;
  38. return U;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement