SHOW:
|
|
- or go back to the newest paste.
1 | int NumeroDeArreglos(char origen[],char destino[], int arreglo[]){ | |
2 | /*Prueba si el archivo inicia correctamente*/ | |
3 | FILE *archivoO, *archivoD; | |
4 | archivoD = fopen(destino, "w"); | |
5 | archivoO = fopen(origen, "r"); | |
6 | if (archivoD == NULL || archivoO == NULL){ | |
7 | return -1; } | |
8 | /*Pasa los valores de pruebas.txt a un arreglo*/ | |
9 | - | int i=0,m=0,j=0,c,d,a,b,e,cont; |
9 | + | int i=0,j=0,c,d,a,b,e,cont; |
10 | int Arreglo[30]; | |
11 | fscanf(archivoO,"%d",&arreglo[0]); | |
12 | while(!feof(archivoO)){ | |
13 | i++; | |
14 | fscanf(archivoO,"%d",&arreglo[i]); | |
15 | } | |
16 | /*Creando los arreglos*/ | |
17 | a=arreglo[j]; | |
18 | j++; | |
19 | for(cont=0;cont<a;cont++){ | |
20 | b=arreglo[j]; | |
21 | j++; | |
22 | d=j; | |
23 | printf("El arreglo %d tiene %d numeros y es: \n",cont+1,b); | |
24 | - | for(c=d;c<=b+1;c++){ |
24 | + | for(c=d;c<b+d;c++){ |
25 | int m=0; | |
26 | Arreglo[m]=arreglo[c]; | |
27 | printf("%d ",Arreglo[m]); | |
28 | m++; | |
29 | j++; | |
30 | } | |
31 | - | e=arreglo[j+1]; |
31 | + | |
32 | e=arreglo[j]; | |
33 | printf("El k es: %d \n",e); | |
34 | /*LLamar a la funcion recursiva*/ | |
35 | int RespuestaUno=ArregloRecursivo(Arreglo,d,e,d); | |
36 | if(RespuestaUno==0){ | |
37 | printf("El arreglo recursivo es:\n"); | |
38 | int p; | |
39 | for(p=0;p<d;p++){ | |
40 | printf("%d ",Arreglo[p]); | |
41 | } | |
42 | } | |
43 | j++; | |
44 | } | |
45 | fclose(archivoO); fclose(archivoD); | |
46 | return 0; | |
47 | } |