Submit solution
Points:
1.00 (partial)
Time limit:
1.0s
Memory limit:
256M
Input:
stdin
Output:
stdout
Author:
Problem source:
Problem type
Allowed languages
C, C#, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch
Cho mảng số nguyên A[] gồm N phần tử, hãy liệt kê theo thứ tự xuất hiện các số thỏa mãn có ít nhất 1 số trái dấu với nó đứng cạnh nó.
Đầu vào
Dòng đầu tiên là số nguyên dương N
Dòng thứ 2 gồm N số nguyên viết cách nhau một vài khoảng trắng
Giới hạn
2<=N<=10^6
-10^6<=A[i]<=10^6
Đầu ra
In ra kết quả của bài toán
Ví dụ :
Input 01
10
1 2 -3 -4 5 -6 7 8 9 10
Output 01
2 -3 -4 5 -6 7
Comments
include <bits/stdc++.h>
define N int(1e6)
using namespace std; int n,a[N]; int main() { cin >> n; for(int i=1;i<=n;i++) cin >> a[i]; if(a[1] > 0 && a[2] < 0 || a[1] < 0 && a[2] > 0) cout << a[1] << " "; for(int i=2;i<n;i++) { if(a[i] > 0) { if(a[i-1] <0 || a[i+1] < 0) cout << a[i] << " "; } else { if(a[i-1] > 0 || a[i+1] > 0) cout << a[i] << " "; } } if(a[n] > 0 && a[n-1] < 0 || a[n] < 0 && a[n-1] > 0) cout << a[n] << " "; return 0; }
moi nguoi cuu e voi e k biet code
ke em
dung de t phot m
xin góp vui một cách bài này:33
include <stdio.h>
define ll long long
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.