输出1-100之间的所有奇数
时间: 2023-05-17 20:06:03 浏览: 153
Sure, here's the code to output all odd numbers between 1 and 100:
for i in range(1, 101):
if i % 2 != 0:
print(i)
相关问题
用c++输出50-100之间所有奇数的累加和
以下是用 C 语言输出 50-100 之间所有奇数的累加和的代码:
```c
#include <stdio.h>
int main() {
int sum = 0;
for (int i = 51; i <= 99; i += 2) {
sum += i;
}
printf("50-100之间所有奇数的累加和为:%d\n", sum);
return 0;
}
```
输出结果为:
```
50-100之间所有奇数的累加和为:1250
```
用c语言输出50-100之间所有奇数的累加和
以下是用 C 语言输出 50-100 之间所有奇数的累加和的代码:
```c
#include <stdio.h>
int main() {
int sum = 0;
for (int i = 51; i <= 99; i += 2) {
sum += i;
}
printf("50-100之间所有奇数的累加和为:%d\n", sum);
return 0;
}
```
输出结果为:
```
50-100之间所有奇数的累加和为:1250
```
相关推荐
![](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)