本文介绍了C编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 #include< math.h> #include< stdio.h> float log(float num); 双日志(双倍数字); 长双日志(长双数); int main() { long double val = 1.0; printf("%lg%lg \ n",val,log(val)); 做{ printf("%d%d \ n",val,log(val)); val ++; } while(val 返回0; } plz调试程序 #include <math.h>#include <stdio.h> float log(float num);double log(double num);long double log(long double num); int main(){long double val = 1.0;printf("%lg %lg\n", val, log(val)); do {printf("%d %d\n", val, log(val));val++;} while (val<11.0); return 0;}plz debug the program 推荐答案 取两个双打,将这些位重新解释为两个整数,并打印 结果。几乎总是你会得到垃圾。例外是值0. Take two doubles, reinterpret the bits as two integers, and print theresults. Almost always you will get garbage. The exception is value 0. 滥用增量运算符。不是错误,但风格很差。在增加某些东西和添加一个仅为恰好是一个的值之间有一个 的区别。在这里你碰巧选择了一个步长, 无论出于何种原因。使val + = 1.0; Misuse of increment operator. Not a bug, but poor style. There is adifference between incrementing something and adding a value that justhappens to be one. Here you just happen to have chosen a step size of one,for whatever reason. Make that val += 1.0; - 免费游戏和编程好东西。 http://www.personal .leeds.ac.uk / ~bgy1mm --Free games and programming goodies. http://www.personal.leeds.ac.uk/~bgy1mm 什么是plz? 你期望程序做什么以及做什么它做错了吗? - Ian Collins。 What''s "plz"? What do you expect the program to do and what does it do wrong? --Ian Collins. 据我所知,plz已离开这个新闻组为alt.illiterate。 它您也不太可能在正确的新闻组中,因为对于log()的多个冲突的原型在C中是不合法的。在 关闭的机会,你真正的意思在comp.lang.c中发帖,你的 " C编程"主题行不是一个大错,并且你愿意为bz以外的其他人提供帮助,无论是谁,这是一个开始: #include< math.h> #include< stdio.h> int main(无效) { int val = 1; for(val = 1; val< 11; val ++) printf("%d% g \ n",val,log(val)); 返回0; } As far as I know, plz has left this newsgroup for alt.illiterate.It is also unlikely that you are in the right newsgroup, since themultiple conflicting prototypes for log() are not legal in C. On theoff chance that you really meant to post in comp.lang.c, and that your"C programming" subject line is not a blunder, and that you are willingto take help for someone other than plz, whoever that is, here''s a start: #include <math.h>#include <stdio.h> int main(void){int val = 1;for (val = 1; val < 11; val++)printf("%d %g\n", val, log(val));return 0;} 这篇关于C编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-30 04:10