Không biết e có làm sai chỗ nào không mà sao khi em in ra nó lại sai các bác ạ.
Mong các bác sữa dùm e với hic
// Bai_1.cpp : Defines the entry point for the console application.
#include "stdafx.h"
#include <iostream>
using namespace std;
#define MAX 100
//nhập mảng
void nhapmang(int a[], int n) {
for (int i = 0; i < n; i++) {
cout << "nhap phan tu a[" << i << "]" << ":";
cin >> a[i];
}
}
//xuất mảng
void xuatmang(int a[], int n) {
for (int i = 0; i < n; i++) {
cout << a[i] << " ";
}
cout << endl;
}
// liệt ke gtri Max trong mảng
void Liet_ke_Max(int a[], int n) {
int max = 0;
int pos;
for (int i = 0; i < n; i++) {
if (max < a[i]) {
max = a[i];
pos = max;
}
}
for (int j = 0; j< n; j++) {
if (a[j] =pos) {
n--;
cout << a[j] << " ";
}
}
}
int _tmain(int argc, _TCHAR* argv[]) {
int a[MAX], n,vt,x;
cout << "nhap phan tu n=";
cin >> n;
nhapmang(a, n);
xuatmang(a, n);
////////////////////////////
Liet_ke_Max(a, n);
return 0;
}


83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?