Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- main()
- {
- int choice,i=1;
- double u,v,t,s,a,b,d,e;
- while(scanf("%d",&choice)!=EOF && choice!=0)
- {
- switch(choice)
- {
- case 1:
- scanf("%lf%lf%lf",&u,&v,&t);
- b=v-u;
- a=b/t;
- d=(u+v)/2;
- s=d*t;
- printf("Case %d: %.3lf %.3lf\n",i,s,a);
- break;
- case 2:
- scanf("%lf%lf%lf",&u,&v,&a);
- b=v-u;
- t=b/a;
- d=(v*v)-(u*u);
- e=2*a;
- s=d/e;
- printf("Case %d: %.3lf %.3lf\n",i,s,t);
- break;
- case 3:
- scanf("%lf%lf%lf",&u,&a,&s);
- b=(u*u)+(2*a*s);
- v=sqrt(b);
- d=v-u;
- t=d/a;
- printf("Case %d: %.3lf %.3lf\n",i,v,t);
- break;
- case 4:
- scanf("%lf%lf%lf",&v,&a,&s);
- b=(v*v)-(2*a*s);
- u=sqrt(b);
- d=v-u;
- t=d/a;
- printf("Case %d: %.3lf %.3lf\n",i,u,t);
- break;
- }
- i++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment