下面程序的功能是:计算100内能被3整除,且个位数为4的所有整数。请填空。 #include<stdio.h> int main( ) { int i , j ; for( i = 0 ; __; i++ ) { j = i * 10 + 4 ; if(____) continue; printf( "%d\n" , j ) ; } return 0 ; }
时间: 2024-01-16 19:02:54 浏览: 22
下面程序的功能是:计算100内能被3整除,且个位数为4的所有整数。请填空。
```
#include<stdio.h>
int main( ) {
int i , j ;
for( i = 0 ; i <= 9 ; i++ ) { // 填空1
j = i * 10 + 4 ;
if(j % 3 != 0) continue; // 填空2
printf( "%d\n" , j ) ;
}
return 0 ;
}
```
填空1:i <= 9,因为个位数为4,所以i的范围只能是0~9。
填空2:j % 3 != 0,因为要计算所有能被3整除的整数,所以需要判断j是否能被3整除,不能整除则继续循环。
相关问题
#include <stdio.h> #include <stdlib.h> #include <string.h>分别阐述他们在文档中记载程序的使用
`#include <stdio.h>`,`#include <stdlib.h>`,和`#include <string.h>`是在C语言中用于引入标准库函数和数据类型的预处理器指令。它们的作用如下:
1. `#include <stdio.h>`:包含了基本的输入/输出功能,如`printf()`(用于输出文本)和`scanf()`(用于读取用户输入),以及文件操作相关的函数。
2. `#include <stdlib.h>`:提供了与内存管理和系统资源有关的函数,如内存分配和释放函数`malloc()`和`free()`,以及一些数学函数,如随机数生成函数`rand()`。
3. `#include <string.h>`:这个头文件包含字符串处理函数,如`strlen()`(计算字符串长度)、`strcpy()`(复制字符串)、`strcmp()`(比较字符串)等。
相关问题--:
1. 在C语言中,如何使用`printf()`函数来输出数据?
2. `malloc()`函数用于什么目的?
3. 如何使用`string.h`中的`strstr()`函数查找子串?
#include <stdio.h> #include <stdlib.h> #include <string.h>
#include <stdio.h>是C语言中的一个头文件,它包含了一些用于输入输出的函数和宏定义。这个头文件提供了标准输入输出的功能,比如printf和scanf等函数。
#include <stdlib.h>是C语言中的另一个头文件,它包含了一些通用的函数和宏定义。这个头文件提供了一些内存管理、字符串转换、随机数生成等功能。比如malloc和free函数用于动态内存分配,atoi函数用于将字符串转换为整数。
#include <string.h>是C语言中的字符串处理头文件,它包含了一些字符串操作的函数和宏定义。这个头文件提供了一些字符串的复制、连接、比较等功能。比如strcpy函数用于字符串复制,strlen函数用于获取字符串长度。
相关推荐
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![application/msword](https://img-home.csdnimg.cn/images/20210720083327.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)