c programming language ___ 5_2.c
#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的更多相关文章
- iOS Swift-元组tuples(The Swift Programming Language)
iOS Swift-元组tuples(The Swift Programming Language) 什么是元组? 元组(tuples)是把多个值组合成一个复合值,元组内的值可以使任意类型,并不要求是 ...
- iOS Swift-控制流(The Swift Programming Language)
iOS Swift-控制流(The Swift Programming Language) for-in 在Swift中for循环我们可以省略传统oc笨拙的条件和循环变量的括号,但是语句体的大括号使我 ...
- iOS Swift-简单值(The Swift Programming Language)
iOS Swift-简单值(The Swift Programming Language) 常量的声明:let 在不指定类型的情况下声明的类型和所初始化的类型相同. //没有指定类型,但是初始化的值为 ...
- Java Programming Language Enhancements
引用:Java Programming Language Enhancements Java Programming Language Enhancements Enhancements in Jav ...
- The Swift Programming Language 英文原版官方文档下载
The Swift Programming Language 英文原版官方文档下载 今天Apple公司发布了新的编程语言Swift(雨燕)将逐步代替Objective-C语言,大家肯定想学习这个语言, ...
- The Swift Programming Language 中文翻译版(个人翻新随时跟新)
The Swift Programming Language --lkvt 本人在2014年6月3日(北京时间)凌晨起来通过网络观看2014年WWDC 苹果公司的发布会有iOS8以及OS X 10.1 ...
- [iOS翻译]《The Swift Programming Language》系列:Welcome to Swift-01
注:CocoaChina翻译小组已着手此书及相关资料的翻译,楼主也加入了,多人协作后的完整译本将很快让大家看到. 翻译群:291864979,想加入的同学请进此群哦.(本系列不再更新,但协作翻译的进度 ...
- 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 ...
- 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 ...
随机推荐
- 特殊情形的Riemann引理
设 $f(x)$ 是 $[0,\infty)$ 上的单调函数, 则对任意固定的 $a$, 有 $\dps{\vlm{n}\int_0^a f(x)\sin nx\rd x =0}$; 若同时还有 $\ ...
- db2常用名词
数据库---表空间----表-----段-------分区 数据库实例:就是server 数据库模式:就是逻辑上的用户
- “/wechat”应用程序中的服务器错误。
对路径“C:\inetpub\wwwroot3\wechat\img\qrcode\”的访问被拒绝. “/wechat”应用程序中的服务器错误. 对路径“C:\inetpub\wwwroot3\wec ...
- JAVA 对象初始化的过程
对象初始化的过程例:Student S = new Student();1.因为new Student()用到了Student类,所以会把它从硬盘上加载进入内存2.如果有static静态代 ...
- 并发工具类(三)控制并发线程数的Semaphore
原文:http://ifeve.com/concurrency-semaphore/#more-14753 简介 Semaphore(信号量)是用来控制同时访问特定资源的线程数量,它通过协调各个线程, ...
- 使用BeanUtils操作Bean属性
package com.wzh.test.beanutils; import java.lang.reflect.InvocationTargetException; import java.text ...
- bootstrap-导航、选项卡
导航: <!-- nav 导航的基础样式 --> <div class="container"> <div class="row" ...
- Valid Number @python
Valid Number Validate if a given string is numeric. Some examples:"0" => true" 0.1 ...
- arp -s 157.55.85.212 00-aa-00-62-c6-09 .... Adds a static entry.
ARp是一个重要的TCp/Ip协议,并且用于确定对应Ip地址的网卡物理地址.实用arp命令,我们能够查看本地计算机或另一台计算机的ARp高速缓存中的当前内容.此外,使用arp命令,也可以用人工方式输入 ...
- 如何将MVC Areas中的某一个页设为起始页
area的默认页: routes.MapRoute( name: "MyArea", url: "{controller}/{action}/{id}", de ...