我们可以使用一维数组和循环来解决此问题。下面是示例代码:
#include
int main() {
int arr[100], n, a, b, count = 0;
printf("Enter number of elements in array: "); scanf("%d", &n);
printf("Enter %d elements: ", n);
for(int i=0; i printf("Enter value of a and b: ");
scanf("%d %d", &a, &b); for(int i=0; i printf("There are %d elements between %d and %d (inclusive)", count, a, b); return 0;
} 首先,我们要求用户输入数组的大小和元素。然后,用户被要求输入要查找的a和b值。接着,我们使用循环遍历整个数组,并使用一个计数器来计算满足条件的元素的数量。最后,我们将结果输出到屏幕上。