tuki2501

bai_2.cpp

Jan 27th, 2021 (edited)
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.   int n, b[50];
  6.   cout << "Nhap n: "; cin >> n;
  7.   for (int i = 0; i < n; i++) {
  8.     cout << "Nhap b[" << i << "] = ";
  9.     cin >> b[i];
  10.   }
  11.   int neg = 0, pos = 0;
  12.   for (int i = 0; i < n; i++) {
  13.     if (b[i] < 0) neg++;
  14.     if (b[i] > 0) pos++;
  15.   }
  16.   cout << "So luong so am: " << neg << '\n';
  17.   cout << "So luong so duong: " << pos << '\n';
  18.   cout << "So luong so khong: " << n - neg - pos << '\n';
  19.   return 0;
  20. }
Add Comment
Please, Sign In to add comment