#include <stdio.h>
#include <ctype.h>
#define BUG printf("here!bug!\n"); int getfloat(float *pn){
int c;
int t;
int intbeforepoint=;
int intafterpoint=;
int intafterpoint_lenth=;
int inte;
int sign,esign;
int ppoint; // 1 means there have point ,otherwise no
float res=; while( isspace(c=getch()) )
;
if(!isdigit(c)&&c!=EOF&&c!='+'&&c!='-'){
ungetch();
return ;
}
sign=(c=='-')?-:;
if(c=='+'||c=='-')
c=getch();
for(intbeforepoint=;isdigit(c);c=getch())
intbeforepoint=*intbeforepoint+(c-'');
ppoint=;
if(c=='.'){
ppoint=;
c=getch();
for(intafterpoint=;isdigit(c);c=getch()){
intafterpoint=*intafterpoint+(c-'');
intafterpoint_lenth++;
}
t=intafterpoint;
while(t%==){
intafterpoint_lenth--;
t=t/;
}
}
if(c=='e'||c=='E'){
c=getch();
esign=;
if(c=='+'||c=='-'){
esign= (c=='+')?:-;
c=getch();
}
while( c==''){
c=getch();
}
for(inte=;isdigit(c);c=getch())
inte=*inte+(c-'');
}
BUG;
if(c!=EOF)
ungetch(c);
res=1.0*intbeforepoint;
t=intafterpoint_lenth;
while(t--)
res*=;
res+=intafterpoint;
t=intafterpoint_lenth;
while(t--)
res/=;
if(esign==-){
while(inte--)
res/=;
}else if(esign==){
while(inte--)
res*=;
}
res*=sign;
*pn=res;
printf("intbeforepoint=%d\n",intbeforepoint);
printf("intafterpoint=%d\n",intafterpoint);
printf("inte=%d\n",inte);
printf("length=%d\n",intafterpoint_lenth);
return c;
}
int main(){
float num[];
int i;
for(i=;i<;++i){
getfloat(&num[i]);
printf("%lf\n",num[i]);
}
return ;
}

5_2.c

c programming language ___ 5_2.c的更多相关文章

  1. iOS Swift-元组tuples(The Swift Programming Language)

    iOS Swift-元组tuples(The Swift Programming Language) 什么是元组? 元组(tuples)是把多个值组合成一个复合值,元组内的值可以使任意类型,并不要求是 ...

  2. iOS Swift-控制流(The Swift Programming Language)

    iOS Swift-控制流(The Swift Programming Language) for-in 在Swift中for循环我们可以省略传统oc笨拙的条件和循环变量的括号,但是语句体的大括号使我 ...

  3. iOS Swift-简单值(The Swift Programming Language)

    iOS Swift-简单值(The Swift Programming Language) 常量的声明:let 在不指定类型的情况下声明的类型和所初始化的类型相同. //没有指定类型,但是初始化的值为 ...

  4. Java Programming Language Enhancements

    引用:Java Programming Language Enhancements Java Programming Language Enhancements Enhancements in Jav ...

  5. The Swift Programming Language 英文原版官方文档下载

    The Swift Programming Language 英文原版官方文档下载 今天Apple公司发布了新的编程语言Swift(雨燕)将逐步代替Objective-C语言,大家肯定想学习这个语言, ...

  6. The Swift Programming Language 中文翻译版(个人翻新随时跟新)

    The Swift Programming Language --lkvt 本人在2014年6月3日(北京时间)凌晨起来通过网络观看2014年WWDC 苹果公司的发布会有iOS8以及OS X 10.1 ...

  7. [iOS翻译]《The Swift Programming Language》系列:Welcome to Swift-01

    注:CocoaChina翻译小组已着手此书及相关资料的翻译,楼主也加入了,多人协作后的完整译本将很快让大家看到. 翻译群:291864979,想加入的同学请进此群哦.(本系列不再更新,但协作翻译的进度 ...

  8. Questions that are independent of programming language. These questions are typically more abstract than other categories.

    Questions that are independent of programming language.  These questions are typically more abstract ...

  9. What is the Best Programming Language to Learn in 2014?

    It’s been a year since I revealed the best languages to learn in 2013. Once again, I’ve examined the ...

随机推荐

  1. java中treemap和treeset实现(红黑树)

    java中treemap和treeset实现(红黑树)   TreeMap 的实现就是红黑树数据结构,也就说是一棵自平衡的排序二叉树,这样就可以保证当需要快速检索指定节点. TreeSet 和 Tre ...

  2. ylbtech-dbs:ylbtech-5,RI(报销发票系统)

    ylbtech-dbs:ylbtech-5,RI(报销发票系统) -- =============================================-- DatabaseName:Pur ...

  3. JAVA 根据用户输入数据求某年到某年有多少天

    实例: import java.util.*; //求某年到某年有多少天 public class Test{ public static void main(String[] args){ Scan ...

  4. Windows下编译使用Aliyun OSS PHP SDK

    摘要: WIN环境下搭建Aliyun OSS PHP SDK编译运行环境.从PHP的安装逐步完成,SDK的编译运行.即使没有任何PHP基础,也能顺利完成. 安装环境:Win7 64 + PHP 5.6 ...

  5. Apache Thrift学习之二(基础及原理)

    Apache Thrift 是 Facebook 实现的一种高效的.支持多种编程语言的远程服务调用的框架.本文将从 Java 开发人员角度详细介绍 Apache Thrift 的架构.开发和部署,并且 ...

  6. FBI传授9秘诀:如何看穿对方在撒谎 z

    第1招:不提及自身和姓名 美国赫特福德郡大学的心理学家韦斯曼说,〝人们在说谎时会本能地把自己从他们所说的谎言中剔除出去〞.所以如果你向某人提问时,他们总是反覆地省略〝我〞,他们就有被怀疑的理由了.反过 ...

  7. Number of Islands

    Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...

  8. 全文检索引擎Solr系列—–全文检索基本原理

    场景:小时候我们都使用过新华字典,妈妈叫你翻开第38页,找到“坑爹”所在的位置,此时你会怎么查呢?毫无疑问,你的眼睛会从38页的第一个字开始从头至尾地扫描,直到找到“坑爹”二字为止.这种搜索方法叫做顺 ...

  9. 服务器压力测试 ab

    1.ab命令原理 Apache自带的ab命令模拟多线程并发请求,测试服务器负载压力,也可以测试nginx.lighthttp.IIS等其它Web服务器的压力(测试其它服务器时需单独下载ab压力测试工具 ...

  10. 基于lucene实现自己的推荐引擎

    基于lucene实现自己的推荐引擎 推荐常用算法之-基于内容的推荐 推荐算法