• Source
    1. #include<stdio.h>
    2. #include<math.h>
    3. int main()
    4. {
    5. int choice,i=1;
    6. double u,v,t,s,a,b,d,e;
    7. while(scanf("%d",&choice)!=EOF && choice!=0)
    8. {
    9. switch(choice)
    10. {
    11. case 1:
    12. scanf("%lf%lf%lf",&u,&v,&t);
    13. b=v-u;
    14. a=b/t;
    15. d=(u+v)/2;
    16. s=d*t;
    17. printf("Case %d: %.3lf %.3lf\n",i,s,a);
    18. break;
    19. case 2:
    20. scanf("%lf%lf%lf",&u,&v,&a);
    21. b=v-u;
    22. t=b/a;
    23. d=(v*v)-(u*u);
    24. e=2*a;
    25. s=d/e;
    26. printf("Case %d: %.3lf %.3lf\n",i,s,t);
    27. break;
    28. case 3:
    29. scanf("%lf%lf%lf",&u,&a,&s);
    30. b=(u*u)+(2*a*s);
    31. v=sqrt(b);
    32. d=v-u;
    33. t=d/a;
    34. printf("Case %d: %.3lf %.3lf\n",i,v,t);
    35. break;
    36. case 4:
    37. scanf("%lf%lf%lf",&v,&a,&s);
    38. b=(v*v)-(2*a*s);
    39. u=sqrt(b);
    40. d=v-u;
    41. t=d/a;
    42. printf("Case %d: %.3lf %.3lf\n",i,u,t);
    43. break;
    44.  
    45. }
    46. i++;
    47. }
    48. return 0;
    49. }