标签:blog http io os for 文件 sp log on
//0的正数次幂合法???哎呀,我去....数学学不好真可怕啊
题目描述:
给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。#include<iostream> #include<cstdio> using namespace std; double getNum(double base,int n) { int flag=1; if(n<0){n*=-1;flag=0;} double sum=1; for(int i=0;i<n;i++) sum*=base; if(!flag)sum=1/sum; return sum; } int main() { int count=0; cin>>count; double base=0; int num=0; for(int i=0;i<count;i++) { cin>>base>>num; if((base-0>-0.000001)&&(base-0<0.000001)) { if(num<=0) printf("INF\n"); else printf("0.00e+00f\n"); } else printf("%.2ef\n",getNum(base,num)); } return 0; } /************************************************************** Problem: 1514 User: hndxztf Language: C++ Result: Accepted Time:540 ms Memory:1520 kb ****************************************************************/
标签:blog http io os for 文件 sp log on
原文地址:http://blog.csdn.net/mnmlist/article/details/39338929