Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cstdlib>
- #include <ctime>
- #include <algorithm>
- int Rand() {
- return (rand() << 16) + rand();
- }
- const int SIZE = 10000000;
- int num[SIZE];
- int main() {
- freopen("d:\\input.txt", "w", stdout);
- int res_time = 0;
- srand(time(0));
- const int TIMES = 1;
- for (int i = 0; i < TIMES; i++) {
- for (int j = 0; j < SIZE; j++) {
- int cur_num = Rand();
- num[j] = cur_num;
- printf("%d\n", cur_num);
- }
- clock_t s_time = clock();
- std::sort(num, num + SIZE);
- clock_t t_time = clock();
- res_time += t_time - s_time;
- }
- freopen("d:\\time.txt", "w", stdout);
- printf("C++: %.2f\n", (double)res_time / TIMES / CLOCKS_PER_SEC);
- }
Advertisement
Add Comment
Please, Sign In to add comment