borsha06

car

Oct 29th, 2014
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.99 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5.     int n,i,m;
  6.     double u,v,a,s,t;
  7.     scanf("%d",&m);
  8.     for(i=1; i<=m; i++)
  9.     {
  10.         scanf("%d",&n);
  11.         if(n==0)
  12.             break;
  13.     if(n==1)
  14.         {
  15.             scanf("%lf %lf %lf",&u,&v,&t);
  16.             a=(v-u)/t;
  17.             s=u*t+0.5*(a*t*t);
  18.             printf("Case %d: %.3lf %.3lf\n",i,s,a);
  19.         }
  20.         else if(n==2)
  21.         {
  22.             scanf("%lf %lf %lf",&u,&v,&a);
  23.             t=(v-u)/a;
  24.             s=u*t+0.5*(a*t*t);
  25.             printf("Case %d: %.3lf %.3lf\n",i,s,t);
  26.         }
  27.         else if(n==3)
  28.         {
  29.             scanf("%lf %lf %lf",&u,&a,&s);
  30.             v=sqrt(u*u+2*a*s);
  31.             t=(v-u)/a;
  32.             printf("Case %d: %.3lf %.3lf\n",i,v,t);
  33.         }
  34.         else if(n==4)
  35.         {
  36.             scanf("%lf %lf %lf",&v,&a,&s);
  37.             u=sqrt(v*v-2*a*s);
  38.             t=(v-u)/a;
  39.             printf("Case %d: %.3lf %.3lf\n",i,u,t);
  40.         }
  41.  
  42.     }
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment