PersonalCorpus 版 (精华区)
寄信人: ooze (烂泥~苦读武侠中)
标 题: 537
发信站: 哈工大紫丁香 (2002年06月19日14:01:24 星期三)
来 源: 202.118.239.224
Your C++ program has solved Ok the problem 537 (Artificial
Intelligence?)
in 0.000 seconds with low memory spent.
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <ctype.h>
void main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\uva\\input537.txt","r",stdin);
freopen("c:\\uva\\output537.txt","w",stdout);
#endif
int j,k,n;
double p,u,i,temp;
char s[1000],ch,mp,mu,mi;
scanf("%d\n",&n);
for (j=1;j<=n;j++) {
gets(s);
mp=0; mu=0;mi=0;
k=0; while (s[k]!='=') k++;
sscanf(s+k+1,"%lf",&temp);
ch=s[k-1];
while (!isalpha(s[k])) k++;
if (s[k]=='m') temp/=1000;
if (s[k]=='k') temp*=1000;
if (s[k]=='M') temp*=1000000;
if (ch=='P') { p=temp; mp=1; }
if (ch=='U') { u=temp; mu=1; }
if (ch=='I') { i=temp; mi=1; }
while (s[k]!='=') k++;
sscanf(s+k+1,"%lf",&temp);
ch=s[k-1];
while (!isalpha(s[k])) k++;
if (s[k]=='m') temp/=1000;
if (s[k]=='k') temp*=1000;
if (s[k]=='M') temp*=1000000;
if (ch=='P') { p=temp; mp=1; }
if (ch=='U') { u=temp; mu=1; }
if (ch=='I') { i=temp; mi=1; }
printf("Problem #%d\n",j);
if (mp==0) printf("P=%.2lfW\n\n",u*i);
if (mu==0) printf("U=%.2lfV\n\n",p/i);
if (mi==0) printf("I=%.2lfA\n\n",p/u);
}
}
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.239.224]
--
※ 转寄:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: 202.118.239.224]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.160毫秒