使用c语言分别用两种循环结构编程实现:输出在100~1000之间的所有奇数,要求每行输出8个数,数与数之间相隔两个空格,而且行间用直线分隔
时间: 2024-04-29 15:22:57 浏览: 14
第一种循环结构:for循环
```
#include <stdio.h>
int main() {
int count = 0;
for (int i = 101; i < 1000; i += 2) {
printf("%d ", i);
count++;
if (count % 8 == 0) {
printf("\n--------\n");
}
}
return 0;
}
```
第二种循环结构:while循环
```
#include <stdio.h>
int main() {
int i = 101, count = 0;
while (i < 1000) {
printf("%d ", i);
count++;
if (count % 8 == 0) {
printf("\n--------\n");
}
i += 2;
}
return 0;
}
```
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![pptx](https://img-home.csdnimg.cn/images/20210720083543.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)