/*------------------------------------------------------ 【程序改错】 -------------------------------------------------------- 功能:一个5位数,判断它是不是回文数。即12321是回文数,个 位与万位相同,十位与千位相同。 ------------------------------------------------------*/ #include<stdio.h> main( ) { /**********FOUND**********/ long ge,shi,qian,wan,x; scanf("%ld",&x); /**********FOUND**********/ wan=x%10000; qian=x%10000/1000; shi=x%100/10; ge=x%10; /**********FOUND**********/ if (ge==wan||shi==qian) printf("this number is a huiwen\n"); else printf("this number is not a huiwen\n"); }
时间: 2023-07-18 21:43:10 浏览: 48
以下是修改后的程序:
```
#include <stdio.h>
int main() {
long ge,shi,qian,wan,x;
scanf("%ld", &x);
wan = x / 10000;
qian = x % 10000 / 1000;
shi = x % 100 / 10;
ge = x % 10;
if (ge == wan && shi == qian)
printf("this number is a huiwen\n");
else
printf("this number is not a huiwen\n");
return 0;
}
```
主要修改如下:
1. 把 `main()` 函数的返回类型改成了 `int`。
2. 把 `x` 的赋值方式修改为 `scanf("%ld", &x)`。
3. 把 `wan`、`qian`、`shi`、`ge` 的计算方式修改为基于数学运算。
4. 把 `if` 语句中的逻辑运算符 `||` 改为 `&&`。
相关问题
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_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)