本文共 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:
程序:
#includeusing 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/