博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
求出数组中元素的总和_数组中所有元素的总和可被给定数K整除
阅读量:2529 次
发布时间:2019-05-11

本文共 710 字,大约阅读时间需要 2 分钟。

求出数组中元素的总和

This program will help to find out the sum of elements in an array which is divisible by a number K. It uses the basic concept of modulo '%' or the remainder of a number.

该程序将帮助找出数组中被数字K整除的元素 。 它使用“%”模或数字余数的基本概念。

Program:

程序:

#include
using namespace std;int main(){
int n, ele; cout<<"Enter the size of the array.\n"; cin>>n; int A[n]; cout<<"Enter elements in the array\n"; for(int i =0;i
>A[i]; } cout<<"Enter the element to be divisible by.\n"; cin>>ele; int sum = 0; for(int i =0;i

Output

输出量

Enter the size of the array.6Enter elements in the array2 3 4 5 6 7Enter the element to be divisible by.3The sum is 9

翻译自:

求出数组中元素的总和

转载地址:http://mkxzd.baihongyu.com/

你可能感兴趣的文章
玉伯的一道课后题题解(关于 IEEE 754 双精度浮点型精度损失)
查看>>
《BI那点儿事》数据流转换——百分比抽样、行抽样
查看>>
哈希(1) hash的基本知识回顾
查看>>
Leetcode 6——ZigZag Conversion
查看>>
dockerfile_nginx+PHP+mongo数据库_完美搭建
查看>>
Http协议的学习
查看>>
【转】轻松记住大端小端的含义(附对大端和小端的解释)
查看>>
设计模式那点事读书笔记(3)----建造者模式
查看>>
交换机划分Vlan配置
查看>>
yum安装Elasticsearch5.x
查看>>
正则表达式
查看>>
Python模块_json & pickle模块
查看>>
Python 模块之_os模块_os是与操作系统交互的接口
查看>>
通通玩blend美工(1)——荧光Button
查看>>
[UWP]了解模板化控件(8):ItemsControl
查看>>
使用JustDecompile修改程序集
查看>>
SQLServer 分组查询相邻两条记录的时间差
查看>>
Swift语言指南(一)--语言基础之常量和变量
查看>>
关于webpack的使用
查看>>
Windows 2008 R2上配置IIS7或IIS7.5中的URLRewrite(URL重写)实例
查看>>