avatar
Untitled

nguyentiendat686868 1K 24th Nov, 2019

#include <iostream>
using namespace std;
int kiemsdx(int k) {
	int temp = 0, c = k;
	while (k != 0)
	{
		temp = temp * 10 + k % 10;
		k = k / 10;
	}
	if (temp == c)
	{
		temp = 0;
		return c;
	}
	return 0;
}
void kiemvt(int a[], int n) {
	for (int i = 0; i < n; i++) {
		if (a[i] == kiemsdx(a[i])) {
			cout << i << "\t";
		}
	}
}
int main() {
	int n, a[100];
	cout << "Nhap so phan tu co trong mang a: ";
	cin >> n;
	for (int i = 0; i < n; i++) {
		do {
			cout << "Nhap so thu " << i << " trong mang: ";
			cin >> a[i];
		} while (a[i] <= 0);
	}
	kiemvt(a, n);
}
C++
Description

No description

To share this paste please copy this url and send to your friends
RAW Paste Data