[Test programming - Sum negative - Tính tổng - Easy]
Cho một dãy số các số nguyên, tìm số đầu tiên trong dãy số thỏa mãn "Tổng của 5 số liền kề phía trước (bao gồm cả nó) là một số âm". Nếu không tìm thấy số nào thỏa mãn thì trả về 0, chú ý tất cả các số trong dãy đều khác 0, dãy số có [10,100] số.
Ví dụ như sau:

[ Output ] Số đầu tiên thỏa mãn điều kiện "Tổng của 5 số liền kề phía trước (bao gồm cả nó) là một số âm", nếu không có số nào thỏa mãn trả về 0.
EngLish:
Given a sequence of integers, find the first number in the sequence correspond to "Total of 5 of the adjacent front (including it) is a negative number." If not found any satisfying number, it returns 0, noting all the numbers in the sequence are different from 0, the sequence with [10,100] number.
[ Input ] At 100 integers, separated by a "space" with a value of [-10000, 10000].
[ Output ] The first number satisfy the condition of "Total of 5 of the adjacent front (including it) is a negative number", if no numbers correspond to returns 0.
Các bạn vui lòng để lại hướng dẫn giải bằng code C/C++ dưới nhận xét của từng bài. Cảm ơn.
( You please leave instructions with the code C / C ++ under review of each post. Thank you. )
![[2] Sum Negative - Tổng số âm - Easy [Company solution]](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjx6bVHmJVjNf8pTQXheNR_KlUlXl_Q9RwHvF4X-AX14KCL-U4rPnVnyd_2EI2MIt3WmXBepneyS7jwQyAcNXW0gsBiPZb5g9aNkR-uvweIYHZLhj3N9-nVI_I-XZO7rrOJ98o6rqJBKei/s1600/so1.png)
No comments:
Post a Comment