Home > Back-end >  Big trouble to help me have a look at me this code, the main function of the first for loop why I ca
Big trouble to help me have a look at me this code, the main function of the first for loop why I ca

Time:09-25

Or how can I still need to improve my code to reach requirements

CodePudding user response:

Copy and paste the code is not than the screenshot is convenient to upload pictures again

CodePudding user response:

Inner and outer loop of a mixture of incremental variable (I)

CodePudding user response:

reference 1st floor CHXCHXKKK response:
copy and paste the code than screenshot is convenient to upload pictures, isn't it

Copy and paste the code looks very messy here so I can only capture

CodePudding user response:

refer to the second floor in the six Payne reply:
, both inside and outside circulation of incremental variable (I) mixed

Ok thank you I try to change

CodePudding user response:

refer to the second floor in the six Payne reply:
, both inside and outside circulation of incremental variable (I) mixed

Bosses I changed cycle is ok according to your result and requirement of the same but also submitted to the platform or to the runtime error is what problem please tell me thank you very much

CodePudding user response:

reference 5 floor weixin_45663602 reply:
Quote: refer to the second floor in the six Payne reply:
increasing inner and outer loop variable (I) mixed

Bosses I changed cycle is ok according to your result and requirement of the same but also submitted to the platform or to the runtime error is what problem please inform thank you very much

Didn't finish see, this problem is the problem of meaning didn't also how to read, I don't know your program logic will not have a problem, but the code or a bit of a problem, f [I] [j] here, your application for int f array type * * [], it said, every member of the array is int * * type, that is, each member of the array is a pointer to the pointer to int *, and as you use methods f [I] [j], you should be to want to apply for a two dimensional array, a two-dimensional array is not so for, you can create some loop array, let your int * * in front of the members of the array to save their first address, but that apparently is too much trouble,
The simplest way is to apply for two-dimensional array like to apply for an array of int arr [a] [b], a, b are integer variables, it is introduced the C99 variable-length array, which USES variable specifies to apply for the length of the array,
If want to use malloc, the simplest way is to apply for a one dimensional array, because the two dimensional array is essentially in order on one dimension, such as int arr [5], [4], that is every four elements as a group, these four elements position is connected, large arrays are five such group, is also connected to the five group, you just locate good bearing, such as to make the arr [I] [j] assignment 1, first apply for memory int * arr=malloc (5 * 4 * sizeof (int)), where the malloc returns void * pointer, do not need to be strong, then * (arr + I * 4 + j)=1, or arr [I * 4 + j]=1;
If must use malloc for two-dimensional arrays, should apply for: int (* arr) [4]=malloc (sizeof (4 * 5 * sizeof (int)), the use of arr [I] [j]=1;

CodePudding user response:

refer to 6th floor six Payne reply:
Quote: refer to the fifth floor weixin_45663602 reply:

Quote: refer to the second floor in the six Payne reply:
, both inside and outside circulation of incremental variable (I) mixed

Bosses I changed cycle is ok according to your result and requirement of the same but also submitted to the platform or to the runtime error is what problem please inform thank you very much

Didn't finish see, this problem is the problem of meaning didn't also how to read, I don't know your program logic will not have a problem, but the code or a bit of a problem, f [I] [j] here, your application for int f array type * * [], it said, every member of the array is int * * type, that is, each member of the array is a pointer to the pointer to int *, and as you use methods f [I] [j], you should be to want to apply for a two dimensional array, a two-dimensional array is not so for, you can create some loop array, let your int * * in front of the members of the array to save their first address, but that apparently is too much trouble,
The simplest way is to apply for two-dimensional array like to apply for an array of int arr [a] [b], a, b are integer variables, it is introduced the C99 variable-length array, which USES variable specifies to apply for the length of the array,
If want to use malloc, the simplest way is to apply for a one dimensional array, because the two dimensional array is essentially in order on one dimension, such as int arr [5], [4], that is every four elements as a group, these four elements position is connected, large arrays are five such group, is also connected to the five group, you just locate good bearing, such as to make the arr [I] [j] assignment 1, first apply for memory int * arr=malloc (5 * 4 * sizeof (int)), where the malloc returns void * pointer, do not need to be strong, then * (arr + I * 4 + j)=1, or arr [I * 4 + j]=1;
If must use malloc for two-dimensional arrays, should apply for: int (* arr) [4]=malloc (sizeof (4 * 5 * sizeof (int)), the use of arr [I] [j]=1;

Wow thank you very much has been solved
  • Related