Solution of Given Back

Python 3

    1 n, x = input().split()
    2 print(' '.join([e for e in input().split() if e != x]))

Rust

    1 #![allow(unused_must_use)]
    2 use std::io;
    3 
    4 fn main() {
    5     let mut nx = String::new();
    6     let mut xs = String::new();
    7 
    8     io::stdin().read_line(&mut nx);
    9     let x = nx.trim().split(" ").collect::<Vec<&str>>()[1];
   10 
   11     io::stdin().read_line(&mut xs);
   12     for e in xs.trim().split(" ").collect::<Vec<&str>>() {
   13         if x != e {
   14             print!("{} ", e);
   15         }
   16     }
   17     println!("");
   18 }

C++

    1 #include <iostream>
    2 using namespace std;
    3 
    4 int n, x, e;
    5 
    6 int main() {
    7     cin>>n>>x;
    8 
    9     while(n--) {
   10         cin>>e;
   11         if(e != x) cout<<e<<" ";
   12     }
   13 
   14     cout<<"\n";
   15     return 0;
   16 }
Questions?

Sponsors Gold