字符串处理
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <sstream>
#include <cctype>
#include <string>
#define mem(a, val) memset((a), (val), sizeof (a))
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef long long LL;
const int maxn = 10100;
string str[maxn];
double x;
int y,z,kase=1;
void print_ans(int i){
double res = (x==0 ? 0:sqrt((y*y+z*z)*1.0 )/x);
printf("Case %d: ",kase++);
printf("The %s of",str[i+1].c_str());
for(int j=0;j<i-1;j++) printf(" %s",str[j].c_str());
printf("'s PPI is %.2lf.\n",res);
}
int main()
{
int T;
scanf("%d",&T);
char src[maxn],c;
gets(src);
while(T--){
cin.getline(src,1000,'\n');
stringstream ss(src);
for(int i=0;;i++){
ss>>str[i];
if(str[i]=="inches"){
x = atof(str[i-1].c_str());
ss>>y>>c>>z;
ss>>str[i+1];
for(int j=0;j<str[i+1].length();j++)
if(isupper(str[i+1][j])) str[i+1][j]+='a'-'A';
print_ans(i);
break;
}
}
}
return 0;
}