删除元素 C++
删除元素
https://ac.nowcoder.com/acm/problem/22228
注意读题,多组测试
#include <iostream> #include <cmath> #include <algorithm> #include <vector> using namespace std; long long a[25]; int main(){ int n, m, flag; while(cin >> n){ flag = 1; for(int i = 0; i < n; ++i){ cin >> a[i]; } cin >> m; for(int i = 0; i < n; ++i){ if(flag && a[i] == m) flag = 0; else cout << a[i] << ' '; } cout << endl; } return 0; }