Tình hình đang rất là tình hình. Mà tình hình là đang ngồi code thì gặp chút rắc rối về kĩ thuật
include - Mấy đại ca vào giúp aloxinh đẹp trai với Cll

Ai giúp em cái code này với Mad

file khaibao.h

Mã:

#include<iostream>

#include <stdlib.h>

#include <time.h>

#define MAX 100

using namespace std;

void intputarray(int a[], int n);

void outputarray(int a[], int n);

int binarysearch (int a[], int n, int x,int left = 0,int right = 20);

file caidat.cpp

Mã:

#include "Header.h"

void intputarray(int a[], int n)

{

for( int i= 0; i<n; i++)

{

a[0] = rand()%n;

a[i] =a[i-1] + rand()%n ;

}

}

void outputarray(int a[], int n)

{

for(int i=0; i<n; i++)

cout<<a[i]<<"\t";

}

int binarysearch (int a[], int n, int x,int left = 0,int right = 20)

{

int mid = (left + right)/2;

if( left >= right)

return -1;

if(x == a[mid])

return mid;

if(x < a[mid])

return binarysearch(a,n,x,left,mid -1);

else

return binarysearch(a,n,x,mid +1,right);

}

file main.cpp

Mã:

#include"Header.h"

void main()

{

srand((unsigned int) time (NULL));

int a[MAX], n = 20, x, kq;

intputarray(a,n);

cout<<"newly created array:\n";

outputarray(a,n);

cout<<"\nPlease enter x which you want to find: ";

cin>>x;

kq = binarysearch(a,n,x);

if(kq = -1)

cout<<"\nNot Found x!";

else

cout<<"\nElement be located at position is: "<<kq;

cout<<endl;

}

Lỗi :

1>d:\save_baitap_tien\timkiem\binarysearch\install.cpp(23): error C2572: 'binarysearch' : redefinition of default parameter : parameter 5

1> d:\save_baitap_tien\timkiem\binarysearch\header.h(10) : see declaration of 'binarysearch'

1>d:\save_baitap_tien\timkiem\binarysearch\install.cpp(23): error C2572: 'binarysearch' : redefinition of default parameter : parameter 4

1> d:\save_baitap_tien\timkiem\binarysearch\header.h(10) : see declaration of 'binarysearch'

Tạm dich: sai tham số mặc định. Nhưng tình hình rất là tình hình, và tình hình là chưa biết sửa chỗ nào
include - Mấy đại ca vào giúp aloxinh đẹp trai với V