Advertisement
borsha06

car(1)

Oct 29th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. int n,i;
  6. double u1,v1,a1,s1,t1,u2,u3,u4,v2,v3,v4,t2,t3,t4,a2,a3,a4,s2,s3,s4;
  7.  
  8. for(i=1;; i++)
  9. {scanf("%d",&n);
  10. if(n==0)
  11. break;
  12. else if(n==1)
  13. {
  14. scanf("%lf %lf %lf",&u1,&v1,&t1);
  15. a1=(v1-u1)/t1;
  16. s1=(u1*t1)+0.5*(a1*t1*t1);
  17. printf("Case %d: %.3lf %.3lf\n",i,s1,a1);
  18. }
  19. else if(n==2)
  20. {
  21. scanf("%lf %lf %lf",&u2,&v2,&a2);
  22. t2=(v2-u2)/a2;
  23. s2=(u2*t2)+0.5*(a2*t2*t2);
  24. printf("Case %d: %.3lf %.3lf\n",i,s2,t2);
  25. }
  26. else if(n==3)
  27. {
  28. scanf("%lf %lf %lf",&u3,&a3,&s3);
  29. v3=sqrt((u3*u3)+(2*a3*s3));
  30. t3=(v3-u3)/a3;
  31. printf("Case %d: %.3lf %.3lf\n",i,v3,t3);
  32. }
  33. else if(n==4)
  34. {
  35. scanf("%lf %lf %lf",&v4,&a4,&s4);
  36. u4=sqrt((v4*v4)-(2*a4*s4));
  37. t4=(v4-u4)/a4;
  38. printf("Case %d: %.3lf %.3lf\n",i,u4,t4);
  39. }
  40.  
  41. }
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement