修改:#include <stdio.h> /**********FOUND**********/ fun ( int m ) { double y = 0, d ; int i ; /**********FOUND**********/ for( i = 100, i <= m, i += 100 ) { d = (double)i * (double)i ; /**********FOUND**********/ y += 1.0 \ d ; } return( y ) ; } int main( ) { int n = 2000 ; printf( "\nThe result is %lf\n", fun ( n ) ) ; }
时间: 2023-07-24 08:17:24 浏览: 62
#include <stdio.h>
double fun ( int m ) { //修改函数返回类型为double型
double y = 0, d ; int i ;
for( i = 100; i <= m; i += 100 ) { //修改for循环的条件表达式
d = (double)i * (double)i ;
y += 1.0 / d ; } //修改除法运算符
return( y ) ;
}
int main( ) {
int n = 2000 ;
printf( "\nThe result is %lf\n", fun ( n ) ) ;
}
相关问题
#include<stdio.h> int main(void) { /*********Found************/ char yy[200] = "ok?
`#include<stdio.h>` 是 C 语言中的预处理指令,用于包含标准输入输出库(stdio)的头文件。这个头文件定义了 C 程序中常用的标准输入输出函数,如 `printf`、`scanf` 和 `fopen` 等。
在给出的代码片段中,`main()` 函数是程序的入口点,标志着程序的开始。`char yy[200] = "ok?"` 是一个字符数组声明,用来存储字符串 "ok?",数组长度为 200 个字符,包括结束符 '\0'。
`/*********Found************/` 这部分是一个标记,可能是为了注释或指示某个特定部分。通常情况下,如果 `yy` 数组被用作用户输入的接收器,它可能会与 `scanf` 函数一起使用。
相关问题--
1. 什么头文件包含了输入输出函数?
2. `main()` 函数在 C 程序中的作用是什么?
3. 描述一下字符数组在 C 语言中的用途。
#include <stdio.h> int fun(double x[], int n) { /************found**********
这是一道C语言的题目,函数fun的作用是将数组x中的元素按照从小到大的顺序排序,并返回排序后的数组中元素个数。下面是完整的代码实现:
```c
#include <stdio.h>
int fun(double x[], int n) {
int i, j;
double temp;
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
if (x[i] > x[j]) {
temp = x[i];
x[i] = x[j];
x[j] = temp;
}
}
}
return n;
}
int main() {
int n, i;
double x[100];
printf("Please input(n>0): ");
scanf("%d", &n);
printf("Please input %d numbers:\n", n);
for (i = 0; i < n; i++) {
scanf("%lf", &x[i]);
}
n = fun(x, n);
printf("\nThe sorted array is:\n");
for (i = 0; i < n; i++) {
printf("%g ", x[i]);
}
printf("\n");
return 0;
}
```
相关推荐
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)