您的位置:首页 > 其它

九度1514

2015-07-10 15:07 323 查看
没有通过,不知道哪里有问题,VS2010

// 9dutest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<stdio.h>
#include<stdlib.h>
#include<iostream>

double power(double data, int num){
    int j;
    double tmp = data;
    for(j=1; j<num; j++){

        tmp *= data;

    }
    return tmp;
}
int eaqualzero(int a){

    if(abs(a-0.0)<0.0000001){

        return 1;
    }
    return 0;
}
void claculatetheinvolution(double base[1000], int exponent[1000],int n){
    int i;
    double tmp;
    for(i=0;i<n;i++){

        tmp = 1.0;
        if(eaqualzero(base[i])){    
            printf("INF\n");
            continue;
        }
        if(exponent[i] == 0){

            printf("%.2ef\n",tmp);
            continue;
        }
        if(exponent[i] < 0){

            tmp = power(base[i],-exponent[i]);
            printf("%.2ef\n", 1.0/tmp);
        }else{

            tmp = power(base[i], exponent[i]);
            printf("%.2ef\n",tmp);

        }

    }

}

int _tmain(int argc, _TCHAR* argv[])
{
    double baseinput[1000];
    int exponentinput[1000];
    int i;
    int n;
    while(scanf("%d",&n) != EOF){

        for(i=0; i<n; i++){

            scanf("%lf %d", &baseinput[i],&exponentinput[i]);
        }

        claculatetheinvolution(baseinput, exponentinput,n);

    }

    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: