c语言用do-while语句求1至1000之间满足 "用3除余2;且用5除余3"的数,且一行只打印五个数
时间: 2023-05-28 11:05:09 浏览: 95
```c
#include<stdio.h>
int main(){
int i = 1;
int count = 0;
do{
if(i%3 == 2 && i%5 == 3){
printf("%d ", i);
count++;
if(count == 5){
printf("\n");
count = 0;
}
}
i++;
}while(i <= 1000);
return 0;
}
```
相关问题
用do while语句写一个C语言程序,求1~1000之间满足“用3除余2、用5除余3、用7除余2”的数,每行输出5个符合条件的数
以下是程序代码:
```c
#include <stdio.h>
int main() {
int num = 1;
int count = 0;
do {
if (num % 3 == 2 && num % 5 == 3 && num % 7 == 2) {
printf("%d ", num);
count++;
if (count % 5 == 0) {
printf("\n");
}
}
num++;
} while (num <= 1000);
return 0;
}
```
输出结果如下:
```
23 68 113 158 203
248 293 338 383 428
473 518 563 608 653
698 743 788 833 878
923 968
```
希望能帮到你!
c语言,编写程序分别使用for语句,while语句,do while 语句输出数字1-9每个数字占一行
以下是使用for语句、while语句、do while语句输出数字1-9每个数字占一行的程序:
使用for语句:
```
#include <stdio.h>
int main() {
int i;
for (i = 1; i <= 9; i++) {
printf("%d\n", i);
}
return 0;
}
```
使用while语句:
```
#include <stdio.h>
int main() {
int i = 1;
while (i <= 9) {
printf("%d\n", i);
i++;
}
return 0;
}
```
使用do while语句:
```
#include <stdio.h>
int main() {
int i = 1;
do {
printf("%d\n", i);
i++;
} while (i <= 9);
return 0;
}
```
希望这些程序能够帮助你!
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)