九度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; }
相关文章推荐
- WCF技术剖析之二十三:服务实例(Service Instance)生命周期如何控制[中篇]
- 一篇文章读懂支付宝9.0改版背后的产品逻辑和战略布局
- ecshop模糊搜索分词插件 dede 开源插件
- android的DrawerLayout
- C# 抽象类
- Scripting.FileSystemObject对象
- Mysql几种索引类型的区别及适用情况
- 虚幻4 C++ 打LOG
- WCF技术剖析之二十三:服务实例(Service Instance)生命周期如何控制[上篇]
- 【Android测试】【第二节】ADB——无线模式
- 用imageNamed加载图片产生的问题
- java-集合下
- Nessus漏洞扫描教程之安装Nessus工具
- 悟空学Linux专栏----第17篇
- BM25 vs Lucene Default Similarity Comparing Precision and Recall
- linux c server and client 简单的通信
- Ubuntu14.04安装Tex
- 图片处理方法
- Servlet--j2e中文乱码解决
- BLCR在80x86架构上的运行总结