C language programming> 20th week ⑤ Please add the main function, the function of this function is: if the previous element of the array a is larger than the next element, it will be saved in the array b and output.

Example: Please add the main function, the function of this function is: if the previous element of the array a is larger than the latter element, it will be saved in the array b and output.

例如,输入{33,49,56,12,66,52,78,95,80,73},则输出56 66 95 80。”。
仅在横线上填写所需的若干表达式或语句,请勿改动函数中的其它任何内容。

代码如下:

#include<stdio.h>
#define N 10
main()
{
    
    
	int i,n=0;
	int a[N]={
    
    33,49,56,12,66,52,78,95,80,73};
	int b[N];
	for(i=0;i<N-1;i++)
		if(a[i]>a[i+1])
			b[n++]=a[i];
	printf("The result is\n");
	for(i=0;i<n;i++)
		printf("b[%d]=%2d\n",i,b[i]);
}

The output running window is as follows:
Insert picture description here

越努力越幸运!
加油,奥力给!!!

Guess you like

Origin blog.csdn.net/qq_45385706/article/details/112799625