上一页 1 ··· 320 321 322 323 324 325 326 327 328 ··· 407 下一页
摘要: 1、 #include <stdio.h> int main(void) { float x1, sum1 = 0.0; for(x1 = 0.0; x1 <= 1.0; x1 += 0.01) { sum1 += x1; } int i; float sum2 = 0.0; for(i = 1; 阅读全文
posted @ 2021-05-20 19:04 小鲨鱼2018 阅读(54) 评论(0) 推荐(0)
摘要: 1、 利用浮点进行循环的时候,计算机不能保证计算机内部转换为二进制后不发生数据丢失,因此随着循环的进行,会发生误差的积累。 #include <stdio.h> int main(void) { int i; float x1 = - 0.01, x2; for(i = 0; i <= 100; i 阅读全文
posted @ 2021-05-20 18:37 小鲨鱼2018 阅读(89) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> #include <math.h> int main(void) { double x; puts("please input an double value."); printf("x = "); scanf("%lf", &x); printf("re 阅读全文
posted @ 2021-05-20 18:07 小鲨鱼2018 阅读(102) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> int main(void) { float x1, sum1 = 0.0; for(x1 = 0.0; x1 <= 1.0; x1 += 0.01) { sum1 += x1; } int i; float x2, sum2 = 0.0; for(i = 阅读全文
posted @ 2021-05-20 15:54 小鲨鱼2018 阅读(59) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> int main(void) { float x1 = -0.01; int x2 = 0; int i; float sum1 = 0.0 , sum2 = 0.0; for(i = 0; i <= 100; i++) { x1 += 0.01; sum 阅读全文
posted @ 2021-05-20 13:03 小鲨鱼2018 阅读(56) 评论(0) 推荐(0)
摘要: 1、 #include <stdio.h> int main(void) { float x1 = -0.01; int x2 = 0; int i; for(i = 0; i <= 100; i++) { printf("x = %f x = %f\n", x1 += 0.01, x2++ / 1 阅读全文
posted @ 2021-05-20 12:55 小鲨鱼2018 阅读(54) 评论(0) 推荐(0)
摘要: 创建一个程序,输入一个实数作为面积,求面积为该实数的正方形的边长。 #include <stdio.h> #include <math.h> int main(void) { double area; puts("please input the area."); printf("area = ") 阅读全文
posted @ 2021-05-20 11:25 小鲨鱼2018 阅读(70) 评论(0) 推荐(0)
摘要: 1、创建一个程序,使用sizeof运算符显示3种浮点型的长度。 3种浮点型: float; double; long double; #include <stdio.h> int main(void) { printf("sizeof(float) = %d\n", sizeof(float)); 阅读全文
posted @ 2021-05-20 11:07 小鲨鱼2018 阅读(132) 评论(0) 推荐(0)
摘要: c语言中<math.h>头文件,计算两点之间的距离。 <math.h>头文件包含基本数学函数的函数原型声明。 1、 #include <stdio.h> #include <math.h> double dist(double x1, double y1, double x2, double y2) 阅读全文
posted @ 2021-05-20 10:39 小鲨鱼2018 阅读(815) 评论(0) 推荐(0)
摘要: c语言中整数的显示 以十进制、二进制、八进制、十六进制显示整数 1、 #include <stdio.h> int count_bits(unsigned x) { int bits = 0; while(x) { if(x & 1U) bits++; x >>= 1; } return bits; 阅读全文
posted @ 2021-05-19 22:50 小鲨鱼2018 阅读(497) 评论(0) 推荐(0)
上一页 1 ··· 320 321 322 323 324 325 326 327 328 ··· 407 下一页