tuki2501

de_1.cpp

Feb 4th, 2021
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int n, k, a[50], cnt = 0;
  6.   cout << "Nhap n: "; cin >> n;
  7.   for (int i = 0; i < n; i++) {
  8.     cout << "Nhap a[" << i << "]: "; cin >> a[i];
  9.     if (a[i] % 3 == 0) cnt++;
  10.   }
  11.   cout << "So so chia het cho 3: " << cnt << endl;
  12.   cout << "Nhap k: "; cin >> k;
  13.   cout << "Cac vi tri co gia tri bang k: ";
  14.   for (int i = 0; i < n; i++) {
  15.     if (a[i] == k) cout << i << ' ';
  16.   }
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment