i.Modify the program so that it finds the maximum crest and the minimum trough for the combined waves. // Implement the pseudocode //Yunfei Pan #include<stdio.h> #include<math.h> #include<assert.h> int main() #define PI 3.1415926 { //initial double p1,p2,h1,h2,w1,w2,r=0,t,l1,l2,r1=0; //input printf("Enter integer wave period (s) and wave height (ft)\nfor wave 1:\n"); scanf("%lf %lf",&p1,&h1); assert(p1>=0&&h1>=0); printf("Enter integer wave period (s) and wave height (ft)\nfor wave 2:\n"); scanf("%lf %lf",&p2,&h2); assert(p2>=0&&h2>=0); t=p1*p2/200; //wave length l1=5.13*p1*p1; l2=5.13*p2*p2; //max hight for (int i=1;i<=200;i++) { w1=h1/2*sin(2*PI*t*i/p1); w2=h2/2*sin(2*PI*t*i/p2); if((w1+w2)>r) r=w1+w2; ...
Comments
Post a Comment