Untitled
plain_text
a month ago
1.2 kB
1
Indexable
Never
#include<bits/stdc++.h> using namespace std; int main() { int i, n; double u, v, a, t, s; for(i = 1 ; ; i++) { cin >> n; if(n == 0) { break; } if(n == 1) { cin >> u >> v >> t; a = (v - u) / t; s = (u*t)+(0.5)* a *(t*t); cout << "case " << fixed << setprecision(3) << i << ": "<< s << " " << a; } else if(n == 2) { cin >> u >> v >> a; t = (v - u) / a; s = (u*t)+(0.5)* a *(t*t); cout << "case " << fixed << setprecision(3) << i << ": " << s << " " << t; } else if(n == 3) { cin >> u >> a >> s; v = sqrt(u*u+2*a*s); t = v-u/a; cout << "case " << fixed << setprecision(3) << i << ": "<< v << " " << t; } else if(n == 4) { cin >> v >> a >> s; u = sqrt(v*v-2*a*s); t = (v - u)/a; cout << "case " << fixed << setprecision(3) << i << ": " << u << " " << t; } } return 0; }