K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

11 tháng 2

Mình đặt A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], bạn tham khảo nhé

1) Python:

def in_so_chan(A): so_chan = [x for x in A if x % 2 == 0] print("Các số chẵn:", so_chan) A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] in_so_chan(A)

2) Java import java.util.Arrays; import java.util.List; public class InSoChan { public static void inSoChan(List<Integer> A) { System.out.print("Các số chẵn: "); for (int x : A) { if (x % 2 == 0) { System.out.print(x + " "); } } System.out.println(); } public static void main(String[] args) { List<Integer> A = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); inSoChan(A); } }

3) C++

#include <iostream> #include <vector> using namespace std; void inSoChan(const vector<int>& A) { cout << "Các số chẵn: "; for (int x : A) { if (x % 2 == 0) { cout << x << " "; } } cout << endl; } int main() { vector<int> A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; inSoChan(A); return 0; }