#include <iostream> #include <cctype> #include <cmath> #include <cstring> #include < Algorithm>using namespace Std;int main () {int T, k = 1; Double U, I, P; Cin >> T; Cin.ignore (); string S; while (t--) {cout << "problem #" << k++ << Endl; Getline (cin,s); U = I = P =-1; int i,j; for (i = 0; i < s.length (); i++) {if (s[i] = = ' = ') {//judgment = number, to data area double num = 0,temp = 0; for (j = i + 1; isdigit (S[j]); j + +)//num computes integer part num = num*10 + s[j]-' 0 '; if (s[j] = = '. ') {//If there are decimals, then temp computes int ct = 0; for (j = j +1; IsDigit (S[j]); j + +) Temp + = (s[j]-' 0 ') *pow (10.0,-(++CT)); } num + = temp; if (s[j] = = ' m ')//judging unit num/= 1000; else if (s[j] = = ' k ') num *= 1000; else if (s[j] = = ' M ') num *= 1000000; if (s[i-1] = = ' U ') u = num; else if (s[i-1] = = ' I ') i = num; else if (s[i-1] = = ' P ') p = num; }} if (P = =-1) printf ("p=%.2fw\n", u*i); else if (U = =-1) printf ("u=%.2fv\n", p/i); else printf ("i=%.2fa\n", p/u); cout << Endl; } return 0;}
UVA 537-artificial Intelligence?