Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scrieti definitia completa a subprogramului care are 3 parametri(a = tablou, n = dimensiunea, k = numar natural < 9).
- Subprogramul returneaza nr de elemente din tablou care sunt miltipli ai nr k si au ultima cifra k.
- /***********************************************************
- Exemplu:
- n = 6;
- a = (9, 273, 63, 83, 93, 123);
- k = 3;
- Subprogramul v-a returna valoarea 4.(273, 63, 93, 123)
- ***********************************************************/
- #include <iostream>
- using namespace std;
- int a[100], n, k;
- void prog(int a[100], int n, int k)
- {
- int nr = 0;
- for(int i = 1; i <= n; i ++)
- if(a[i] % k == 0 && a[i] % 10 == k)
- nr++;
- cout << nr;
- }
- int main()
- {
- cout << " n = "; cin >> n;
- cout << " k = "; cin >> k;
- for(int i = 1; i <= n; i ++)
- {
- cout << "a[" << i << "]= ";
- cin >> a[i];
- }
- prog(a, n, k);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement