Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<time.h>
- int Hanoi(int n){
- if(n == 1)
- return 1;
- else
- return 2 * Hanoi(n-1) + 1;
- }
- int main(int argc, char ** argv)
- {
- int i;
- int m[10];
- double t[10];
- FILE * f;
- f = fopen("Fichero6a.txt", "w+");
- for (i = 0; i < 10; i++)
- {
- clock_t start = clock();
- Hanoi(i+1);
- t[i] = ((double)(clock() - start)/CLOCKS_PER_SEC);
- m[i] = Hanoi(i+1);
- }
- for(i = 0; i < 10; i++)
- {
- fprintf(f,"%d %f %d\n",i+1, t[i], m[i]);
- }
- fclose(f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement