Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define N 40
- #include <stdio.h> //für printf()
- #include <time.h> //für clock()
- #include <stdlib.h> //für rand()
- #include "array.cpp"
- extern void sort(int Array[]);
- int main()
- {
- int A[N]={0,6,7,7,3,1,0,3,6,4,7,9,2,1,3,9,4,9,9,9,2,4,2,0,7,5,7,2,8,9,3,5,3,4,8,1,4,9,5,1};
- int time1,time2,thou,sec;
- time1 = clock();
- sort(A);
- time2 = clock();
- for(int i=0; i < N; i++)
- {
- printf("%d",A[i]);
- }
- printf("\nTime1: %i",time1);
- printf("\nTime2: %i",time2);
- printf("\nDiff : %i",time2-time1);
- thou = (time2-time1) * 1000 / CLOCKS_PER_SEC;
- sec = thou / 1000;
- thou -= sec * 1000;
- printf ("\nDie Zeit fuer 80.000 Elemente betraegt: %ld.%09ld sec.\n\n", sec, thou,"\n");
- /*RANDOM-Generator: schreibt 40x2000 Random-Zahlen in eine Textdatei
- srand (time(NULL));
- char string[80]={'x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',',','x',','};
- FILE * pFile;
- pFile = fopen ("array.txt","w"); //a+: Update w: Neu schreiben/ueberschreiben
- if (pFile!=NULL)
- {
- for(int i=0; i < 2000; i++)
- {
- for(int j=0; j < 40; j++) //Neue Zeile generieren
- {
- string[i*2] = rand() % 10 + 48; //ASCII 48d...57d: '0'...'9'
- }
- for(int k=0; k < 80; k++) //Zeile schreiben
- {
- fputc (string[j],pFile);
- }
- fputc ('\n',pFile); //Newline
- }
- fclose (pFile);
- }*/
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment