You are provided an array A of the size N that contains non-negative integers. Your task is to determine whether the number that is formed by selecting the last digit of all the N numbers is divisible by 10.
Example:
Input: n = 5, a = [85,25,65,21,84]
Output: No
Approach
C++
#include <bits/stdc++.h>using namespace std;bool divisibility(int n, int a[]){if (a[n - 1] % 10 == 0)return true;return false;}int main(){int n = 5;int a[n] = {85, 25, 65, 21, 84};if (divisibility(n, a))cout << "Yes\n";elsecout << "No\n";}
No comments:
Post a Comment