Artificial Intelligence?

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


using namespace std;


#define m 0.001
#define k 1000.0
#define M 1000000.0
double P, U, I;


int main()
{
    int n;
    char s;
    char ss;
    char pu[5];
    double x;
    bool a,b,c;
    scanf("%d",&n);
    getchar();
    for( int cnt = 1; cnt <= n; cnt++)
    {
        a = b= c = 0;


        while(1)
        {
            s = getchar();
            if(s == '\n')
            {


                printf("Problem #%d\n",cnt);
                if(a == 0)
                    printf("I=%.2lfA\n",P/U);
                else if( b == 0)
                    printf("U=%.2lfV\n",P/I);
                else
                    printf("P=%.2lfW\n",I*U);
                printf("\n");
                break;
            }
            if(s == '=')
            {


                scanf("%lf",&x);
                scanf("%s",pu);
                int len = 0;


                while( pu[len] != '\0')
                {


                    if(pu[len] =='m')
                      x*= m;
                    else if(pu[len] == 'M')
                      x*= M;
                    else if(pu[len] == 'k')
                      x*= k;


                    else  if(pu[len] == 'W')
                    {
                        P = x;
                        c = 1;
                        break;
                    }
                    else if(pu[len] == 'V')
                    {
                        U = x;
                        b = 1;
                        break;
                    }
                    else if(pu[len] == 'A')
                    {
                        I = x;
                        a = 1;
                        break;
                    }
                    len++;
                }


            }
        }




    }
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值