| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这道题真的不是出来玩弄人的吗?#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main()
{
int t;
cin>>t;
cin.get();
for (int l=1;l<=t;l++)
{
string king;
getline(cin,king);
double p=0,u=0,i=0;
int queen=king.length();
string us="\0",ps="\0",is="\0";
for (int j=0;j<queen;j++)
{
if (king[j]=='P' && king[j+1]=='=')
{
int horace=j;
horace++;
while(king[horace]!='W')
{
horace++;
ps=ps+king[horace];
}
}
else if (king[j]=='I' && king[j+1]=='=')
{
int horace=j;
horace++;
while(king[horace]!='A')
{
horace++;
is=is+king[horace];
}
}
else if (king[j]=='U' && king[j+1]=='=')
{
int horace=j;
horace++;
while(king[horace]!='V')
{
horace++;
us=us+king[horace];
}
}
}
int lus=us.length(),lis=is.length(),lps=ps.length();
if (us[lus-2]!='M' && us[lus-2]!='m'&&us[lus-2]!='k')
{
int horace=1;
for (int o=lus-2;o>=0;o--)
{
if (us[o]=='.')
{
u=u/horace;
horace=1;
}
else
{
u+=(us[o]-'0')*horace;
horace*=10;
}
}
}
else
{
int horace=1;
for (int o=lus-3;o>=0;o--)
{
if (us[o]=='.')
{
u=u/horace;
horace=1;
}
else
{
u+=(us[o]-'0')*horace;
horace*=10;
}
}
if (us[lus-2]=='M')
u*=1000000;
else if(us[lus-2]=='m')
u*=0.001;
else if(us[lus-2]=='k')
u*=1000;
}
if (is[lis-2]!='M' && is[lis-2]!='m'&&is[lis-2]!='k')
{
int horace=1;
for (int o=lis-2;o>=0;o--)
{
if (is[o]=='.')
{
i=i/horace;
horace=1;
}
else
{
i+=(is[o]-'0')*horace;
horace*=10;
}
}
}
else
{
int horace=1;
for (int o=lis-3;o>=0;o--)
{
if (is[o]=='.')
{
i=i/horace;
horace=1;
}
else
{
i+=(is[o]-'0')*horace;
horace*=10;
}
}
if (is[lis-2]=='M')
i*=1000000;
else if(is[lis-2]=='m')
i*=0.001;
else if(is[lis-2]=='k')
i*=1000;
}
if (ps[lps-2]!='M' && ps[lps-2]!='m'&&ps[lps-2]!='k')
{
int horace=1;
for (int o=lps-2;o>=0;o--)
{
if (ps[o]=='.')
{
p=p/horace;
horace=1;
}
else
{
p+=(ps[o]-'0')*horace;
horace*=10;
}
}
}
else
{
int horace=1;
for (int o=lps-3;o>=0;o--)
{
if (ps[o]=='.')
{
p=p/horace;
horace=1;
}
else
{
p+=(ps[o]-'0')*horace;
horace*=10;
}
}
if (ps[lps-2]=='M')
p*=1000000;
else if(ps[lps-2]=='m')
p*=0.001;
else if(ps[lps-2]=='k')
p*=1000;
}
if (ps=="\0")
{
cout<<"Problem #"<<l<<endl;
cout<<fixed<<setprecision(2)<<"P="<<u*i<<"W"<<endl<<endl;
}
else if (us=="\0")
{
cout<<"Problem #"<<l<<endl;
cout<<fixed<<setprecision(2)<<"U="<<p/i<<"V"<<endl<<endl;
}
else if (is=="\0")
{
cout<<"Problem #"<<l<<endl;
cout<<fixed<<setprecision(2)<<"I="<<p/u<<"A"<<endl<<endl;
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator