函数int find(int x0,int x1,int a[],int b[])的功能是找出a数组中在x0至x1之间所有能被3整除的数存入b数组中,返回b数组中元素的个数,并打印输出b数组元素。编写main函数,调用find函数求出15~50之间所有满足条件的整数。
1条回答 默认 最新
- 浪客 2022-03-30 21:53关注
#include<stdio.h> #define N 100 int find(int x0,int x1,int a[],int b[]); int main() { int a[N],b[N],count,i; for (i=0;i<N;i++) { a[i]=i+1; } count=find(15,50,a,b); for (i=0;i<count;i++) { printf("%d ",b[i]); } return 0; } int find(int x0,int x1,int a[],int b[]) { int count=0,i; for (i=0;i<N;i++) { if(a[i]>=x0 && a[i] <=x1 && a[i]%3==0) { b[count]=a[i]; count++; } } return count; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥60 ESP32怎么烧录自启动程序
- ¥50 html2canvas超出滚动条不显示
- ¥15 MATLAB四叉树处理长方形tif文件
- ¥15 java业务性能问题求解(sql,业务设计相关)
- ¥15 52810 尾椎c三个a 写蓝牙地址
- ¥15 elmos524.33 eeprom的读写问题
- ¥15 使用Java milo连接Kepserver服务端报错?
- ¥15 用ADS设计一款的射频功率放大器
- ¥15 怎么求交点连线的理论解?
- ¥20 软件开发方法学习来了