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
28Tech không thích số 28 vì thế anh ta yêu cầu bạn xóa hết mọi phần tử trong mảng A[] có giá trị là 28. Sau đó in ra mảng sau khi xóa, nếu mảng không còn phần tử nào thì in ra EMPTY.
Đầu vào
Dòng 1 là N : số phần tử trong mảng
Dòng 2 là N phần tử cách nhau 1 khoảng trắng
Giới hạn
1<=N<=1000
0<=A[i]<=1000
Đầu ra
In ra mảng sau khi xóa
Ví dụ :
Input 01
5
1 28 28 3 4
Output 01
1 3 4
Comments
include<bits/stdc++.h>
using namespace std;
int main() { int n; cin >> n; int check = 0; for(int i = 0; i < n; i++) { int x; cin >> x; if(x != 28) { cout << x << " "; check = 1; } } if(check == 0) cout << "EMPTY"; }
// góp vui tí OOP:))
include <iostream>
include <vector>
class HaiTamTech { public: HaiTamTech() : NumberOfValue(0) {}
private: int NumberOfValue; std::vector<int> vec; };
int main() { std::iosbase::syncwith_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);
}
ý tưởng đơn giản nhất là đẩy vào mảng mới, thế thôi nhá , tự hiểu
Thank b nha
n = int(input()) a = list(map(int,input().split())) res = [] for i in a: if i != 28: res.append(i) if len(res) == 0: print('EMPTY') else: print(*res)
include <bits/stdc++.h>
using namespace std; typedef long long ll; typedef long double lb; //const ; //Khai bao
//Ham
int main() { iosbase::syncwith_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(".INP", "r", stdin); //freopen(".OUT", "w", stdout); int n ; cin >> n ; vector<int> a(n); for (int i=0;i<n;i++) { cin >> a[i]; } for (int i=0;i<n;i++) { if(a[i]==28) { a.erase(a.begin()+i); i--; n--; } } if(n==0) { cout << "EMPTY"; } else { for (int c:a) cout << c << " "; } return 0; }
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.