私は次の宿題を与えられました。
nlogn、n2、n5、2n、および n! を実行するのにかかる時間をコンピューターでテストするプログラムを作成します。n=5、10、15、20の追加。
コードを書きましたが、常に実行時間が 0 になっています。誰か助けてくれませんか? ありがとう
#include <iostream>
#include <cmath>
#include <ctime>
using namespace std;
int main()
{
float n=20;
time_t start, end, diff;
start = time (NULL);
cout<<(n*log(n))*(n*n)*(pow(n,5))*(pow(2,n))<<endl;
end= time(NULL);
diff = difftime (end,start);
cout <<diff<<endl;
return 0;
}