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 ...
随机推荐
- [实变函数]5.3 非负可测函数的 Lebesgue 积分
本节中, 设 $f,g,f_i$ 是可测集 $E$ 上的非负可测函数, $A,B$ 是 $E$ 的可测子集. 1 定义: (1) $f$ 在 $E$ 上的 Lebesgue 积分 ...
- JavaScript面向对象编程指南
引言 面向对象程序设计 基本数据类型.数组.循环及条件表达式 基本数据类型 函数 函数Function 预定义函数 变量的作用域 函数也是数据 闭包 对象 原型 原型 继承 原型链 浅拷贝与深拷贝 原 ...
- R %operator% 含义
%foo% is the syntax for a binary operator. In base R: %in%: '"%in%" <- function(x, tabl ...
- editplus格式化xml文档
使用editplus打开xml文档,发现文件内容没有格式化,非常难看,使用IE9打开这个xml文档是格式化的,但是IE9打开不能编辑. 在网上找了一些资料发现能够通过一个小插件来是editplus格式 ...
- C++ primer 练习9.49
如果一个字母延伸到中线之上,如d或f,则称其有上出头部分.如果一个字母延伸到中线之下,如p或g, 则称其有下出头部分.编写程序,读入一个单词,输出最长的即不包含上出头部分,也不包含下出头部分单 词. ...
- java静态内部类
public class StaticInnerClass { int x=100; static class inner{ void doitInner() ...
- 4.1.1 A - Calendar(简单线性表)(日期查找)(数组应用)
Description A calendar is a system for measuring time, from hours and minutes, to months and days, a ...
- GL_INVALID_VALUE(0X501)
当android应该打开GPU的支持后, 有些手机会出现黑屏.闪屏等现象. 跟踪控制台, 会打印日志GL_INVALID_VALUE(0X501). 参考资料:http://mobile.riaos. ...
- cocos2d 3.0自定义事件答疑解惑
疑惑一:在事件分发中修改订阅者 ,对于这个的理解. 事件的分发是可以嵌套的,cocos2dx使用_inDispatch来保存当前嵌套的深度,当调用第一个dispatchEvent的时候,_inDisp ...
- 检测网页是否可以打开, 再使用IE打开网页
//检测是否能连接网页 BOOL CanLinkWebPage(string strUrl) { /*clock_t start, finish; double duration; start = c ...