#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. php表单数据验证类

    非常好用方便的表单数据验证类 <?php //验证类 class Fun{ function isEmpty($val) { if (!is_string($val)) return false ...

  2. php序列化,反序列化

    serialize("数组"); //序列化的函数 序列化示范:serialize(array('1'=>1235622,'2'=>'4142122')); unser ...

  3. jsp页面编译成Servlet类文件

    package org.apache.jsp; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.js ...

  4. DEDE织梦,文章页里的幻灯调用,能调用全部栏目的吗

    arclist 是必须要有 typeid 设置的,如果你没设置,默认是取的当前栏目的 typeid,而首页取到的是 top,所以你强制指定typeid=top就可以了.---------------- ...

  5. DNS拦截的处理

    在用webSocket来实现长连接时,我们的链接对象使用了域名.但是再某些省份的网络下,发生了DNS拦截.踹改.导致使用某个域名链接,发生连接不上的现象.[解决方案] 在多次尝试原有域名不能使用的情况 ...

  6. Oracle 11gR2 Database UNDO表空间使用率居高不下-转载

    客户的数据库是Oracle Database 11.2.0.3.0 for AIX 6.1 64bit的单机数据库.客户查询DBA_FREE_SPACE发现UNDO表空间的使用率高达98%以上.客户的 ...

  7. 翻译:深入 AngularUI Router

    原文地址:http://www.ng-newsletter.com/posts/angular-ui-router.html ui-router: https://angular-ui.github. ...

  8. Win2D 官方文章系列翻译 - 处理设备丢失

    本文为个人博客备份文章,原文地址: http://validvoid.net/win2d-handling-device-lost/ “设备丢失”是指 GPU 设备失效无法继续进行渲染的情况.GPU ...

  9. 用Asroute解决复杂状态切换问题

    项目地址:https://github.com/boycy815/asroute 首先明确几个概念 状态: 很多情况下,一个复杂的UI组件可能会有很多种不同的“状态”,不同的“状态”下组件本身对外界会 ...

  10. 【LeetCode】5. Longest Palindromic Substring 最大回文子串

    题目: Given a string S, find the longest palindromic substring in S. You may assume that the maximum l ...