Open utterances-bot opened 1 year ago
using namespace std;
int main() { int n; cin >> n; // Nhập số lượng phần tử trong mảng int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i]; // Nhập các phần tử của mảng
}
int total_sum = 0;
int even_count = 0;
int last_positive = 0;
for (int i = 0; i < n; i++) {
total_sum += arr[i]; // Tính tổng các số trong mảng
if (arr[i] % 2 == 0) {
even_count++; // Đếm số lượng số chẵn trong mảng
}
if (arr[i] > 0) {
last_positive = arr[i]; // Gán số dương cuối cùng
}
}
cout << total_sum << " " << even_count << " " << last_positive << endl;
return 0;
}
undefined - Luyện Code Online
https://oj.luyencode.net/contest/158/problem/Mang01