Potrzebuję program w c++ który do tablicy o podanej przez użytkownika wielkości wpisuje się liczbę i mierzy czas wyszukiwania tej liczby z tablicy
#include <cstdlib>
#include <iostream>
#include <ctime>
#include <time.h>
#include <sys/time.h>
using namespace std;
int main()
{
int* x;
x=new int;
*x=5646;
cout<<*x<<endl;
int n;
cout<<"poodaj liczbe wywolan n: ";cin>>n;
int* t;
t=new int[n];
srand(time(NULL));
for (int i=0;i<n;i++)
{t[i]=rand();}
clock_t start, stop;
double time;
start=clock();
for(int i=0; i<n; i++){
if(t[i]==*x){
stop=clock();
break;
}
}
stop=clock();
cout<<endl;
time = (double)(stop - start)/CLOCKS_PER_SEC;
cout<<"Czas wykonywania funkcji dla n wywołan: "<<time<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
takie coś zrobiłem ale nie działa tak jak powinno mógłby ktoś to przerobić albo pomóc...