[Mảng 1 Chiều Cơ Bản]. Bài 34. Unique array

View as PDF

Submit solution

Points: 1.00 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Author:
Problem source:
28Tech
Problem type
Allowed languages
C, C#, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Cho mảng A[] gồm N phần tử, nhiệm vụ của bạn là xóa các phần tử trong mảng sao cho không có 2 phần tử liền kề có giá trị giống nhau.

Ví dụ : mảng A[] = {1, 1, 2, 2, 2, 3, 3, 2, 1, 4} sau khi xóa sẽ được A[] = {1, 2, 3, 2, 1, 4}


Đầu vào

Dòng 1 gồm N

Dòng 2 gồm N số của mảng A[]


Giới hạn

1<=N<=1000

0<=A[i]<=100


Đầu ra

In ra mảng sau khi xóa


Ví dụ :

Input 01
11
2 3 3 0 0 0 3 3 3 3 4
Output 01
2 3 0 3 4

Comments

Please read the guidelines before commenting.



  • 1
    nguyen_luong_an  commented on Dec. 18, 2024, 10:02 p.m.

    <3


  • 0
    theguy777_jaboi  commented on Nov. 15, 2024, 1:00 p.m.


  • -2
    theguy777_jaboi  commented on Nov. 15, 2024, 12:23 p.m.


  • -12
    khuemih  commented on Aug. 24, 2024, 2:12 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -1
    luan54bc  commented on Aug. 20, 2024, 1:31 p.m.

    include <bits/stdc++.h>

    using namespace std; void d(int a[], int n){ int i = 0; while ( i < n ){ while ( i < n - 1 && a[i] == a[i + 1]){ for ( int j = i; j < n - 1; j++){ a[j] = a[j + 1]; } n--; } i++; } } int main(){ int n; cin >> n; int a[n]; for ( int i = 0; i < n; i++){ cin >> a[i]; } d(a, n); for ( int i = 0; i < n; i++){ cout << a[i] << " "; } return 0; } tại sao em in ra output thì lúc trc đúng nhưng lúc gặp số 4 thì nó lại ra nhiều số 4 vậy ạ