在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
[解析]软件设计中模块划分应遵循的准则是高内聚低偶
#include <stdio.h> double fun(double e) { int i, k; double s, t, x; s=0; k=1; i=2; /**********found**********/ x=3.0/4; /**********found**********/ while(x > e) { s=s+k*x; k=k* (-1); t=2*i; /**********found**********/ x=(t+1)/(t*t); i++; } return s; } main() { double e=1e-3; printf("\nThe result is: %f\n",fun(e)); }
#include <stdio.h> /************found************/ double fun ( int n ) { int a, b, c, k; double s; s = 0.0; a = 2; b = 1; for ( k = 1; k <= n; k++ ) { /************found************/ s = s + (double)a / b; c = a; a = a + b; b = c; } return s; } main( ) { int n = 5; printf( "\nThe value of function is: %lf\n", fun ( n ) ); }
#include <stdio.h> #define M 4 int fun (int a[][M]) { int i,j,max=a[0][0]; for(i=0;i<2;i++) for(j=0;j<M;j++) if(max<a[i][j]) max=a[i][j]; return max; } main( ) { int arr[2][M]={5,8,3,45,76,-4,12,82} ;void NONO (); printf("max =%d\n", fun(arr)) ; NONO( ) ; } void NONO () {/* 本函数用于打开文件,输入数据,调用函数,输出数据,关闭文件。 */ FILE *wf ; int arr[][M]={5,8,3,90,76,-4,12,82} ; wf = fopen("out.dat","w") ; fprintf(wf, "max=%d\n", fun(arr)) ; fclose(wf) ; }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论