/*------------------------------------------------------- 【程序改错】 --------------------------------------------------------- 题目:从键盘上输入若干学生的成绩,统计并输出最高成绩和最低成绩, 当输入负数时结束输入。 -------------------------------------------------------*/ #include <stdio.h> main() { float x,amax,amin; scanf("%f",&x); amax=x; amin=x; /***********ERROR***********/ while(x<0) { /***********ERROR***********/ if(x<amax) amax=x; /***********ERROR***********/ if(amin<x) amin=x; scanf("%f",&x); } printf("\nmax=%f\nmin=%f\n",amax,amin); }
时间: 2023-07-01 21:21:16 浏览: 42
修改后的程序如下:
```c
#include <stdio.h>
int main() {
float x, amax, amin;
scanf("%f", &x);
amax = x;
amin = x;
while (x >= 0) { // 修正循环条件
if (x > amax)
amax = x;
if (x < amin)
amin = x;
scanf("%f", &x);
}
printf("\nmax=%f\nmin=%f\n", amax, amin);
return 0;
}
```
修改说明:
1. 循环条件应该是 `x >= 0`,而不是 `x < 0`。
2. 在判断最大值和最小值时,应该使用 `>` 和 `<`,而不是 `<` 和 `>`。
相关问题
pyinstaller: error: unrecognized arguments: --add-dateimages/*;video/*;music/*-F
看起来你在命令行中使用了 `--add-date` 而不是正确的 `--add-data` 参数。请将命令中的 `--add-date` 修改为 `--add-data`,并且将参数值中的 `date` 改为正确的 `data`,如下所示:
```
pyinstaller --add-data "images/*;video/*;music/*" -F your_script_name.py
```
这个命令将会把 `images`、`video` 和 `music` 文件夹中的所有文件都打包到可执行文件中。`-F` 参数表示将所有依赖项都打包到一个单独的可执行文件中。
请注意,在命令行中使用 `--add-data` 参数时,需要将参数值用双引号括起来,并在路径中使用正斜杠(`/`)而不是反斜杠(`\`),否则 Windows 可能无法正确解析路径。
我想补齐每一行对称的-代码该怎么写--* -*** ***** -*** --*
以下是补齐每一行对称的代码:
```python
n = 5
for i in range(n):
if i < n//2:
print('-'*(n//2-i) + '*'*(2*i+1) + '-'*(n//2-i))
else:
print('-'*(i-n//2) + '*'*(2*(n-i)-1) + '-'*(i-n//2))
```
输出结果为:
```
--*--
-***-
*****
-***-
--*--
```
相关推荐
![xz](https://img-home.csdnimg.cn/images/20210720083646.png)
![java](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.png)
![-](https://csdnimg.cn/download_wenku/file_type_lunwen.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)