Mọi người ơi cho em hỏi sao #define trong codeblock lại gặp lỗi này vậy ạ
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <cmath>
#include <string.h>
#include <windows.h>
using namespace std;
#define n 5
void nhap_mang(int a[],int n)
{
for(int i=0;i<n;i++)
{
cout<<"nhập phần tử thứ a["<<i+1<<"] : ";
cin>>a[i];
}
}
void xuat_mang(int a[],int n)
{
for(int i=0;i<n;i++)
{
cout<<"phần tử thứ a["<<i+1<<"] : "<<a[i]<<"\n";
}
}
int tim_kiem_tuyen_tinh(int a[],int n,int x)
{
for(int i=0;i<n;i++)
{
if(a[i]==x)
{
return 1;//true
}
}
return 0;//false
}
int tim_x_xuat_hien_bao_nhieu_lan(int a[],int n,int x)
{
int dem=0;
for(int i=0;i<n;i++)
{
if(a[i]==x)
{
dem++;//true
}
}
return dem;
}
int main()
{
SetConsoleOutputCP(65001);
int a[100];
int n;
printf("nhập n : ");
scanf("%d",&n);
nhap_mang(a,n);
xuat_mang(a,n);
int x;
printf("nhập x : ");
scanf("%d",&x);
int ketqua=tim_kiem_tuyen_tinh(a,n,x);
if(ketqua==1)
{
printf("tìm thấy\n");
}
else
{
printf("không tìm thấy\n");
}
cout<<x<<" xuất hiện số lần là : "<<tim_x_xuat_hien_bao_nhieu_lan(a,n,x)<<"\n";
return 0;
}