Witam, czy ten kod jest poprawny?
#include "stdio.h"
#include<conio.h>
using namespace std;
const int n=10;
int tab[n];
int po[n];
void merge(int t1, int sr, int t2)
{
int i,q,j;
for(i=t1; i<=t2; i++)
po[i]=tab[i];
i=t1;
q=t1;
j=sr+1;
while(i <= sr && j <= t2)
{
if(po[i]<po[j])
tab[q++]=po[i++];
else
tab[q++]=po[j++];
}
while(i <= sr) tab[q++]=po[i++];
}
void merge_sort(int t1, int t2)
{
int sr;
if(t1<t2)
{
sr=(t1+t2)/2;
merge_sort(t1,sr);
merge_sort(sr+1,t2);
merge(t1,sr,t2);
}
}
int main(){
for(int i=0;i<n;i++)
scanf("%d", &tab[i]);
merge_sort(0,n-1);
printf("%d", tab[n-2]);
getch();
}
Błąd mam taki:
/rq/91686.src18: error: conio.h: No such file or directory
/rq/91686.src2: warning: no newline at end of file
/rq/91686.src: In function 'int main()':
/rq/91686.src error: 'getch' was not declared in this scope