//function function pointer to create 10 X storage address, each address storage 10 4 bytes of data; The first address to store random data, the second address data is stored in the first address data on 1, the third address is stored in the second data plus 1
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include
#include
#include
Int * * t_rand ();
using namespace std;
Int main ()
{
Int * * g=t_rand ();
for(int i=0; I<10; I++)
{
For (int j=0; J & lt; 10; J++)
{
cout
cout
getchar();
return 0;
}
Int * * t_rand ()
{
Time_t t;
Srand ((unsigned) time (& amp; T));
Int * * x;
X=(int) * * malloc (10 * sizeof (int *));
Int * p;
P=(int *) malloc (10 * sizeof (int));
For (int I=0; I<10; I++)
{
* (p + I)=rand () & amp; 100;
}
X=& amp; p;
For (int I=1; I<10; I++)
{
Int * o;
O=(int *) malloc (10 * sizeof (int));
For (int j=0; J<10; J++)
{
Int temp=* (*) (x + I - 1 + j) + 1;
* (o + j)=temp;
}
* (x + I)=o;
}
Return the x;
}
CodePudding user response:
Int * * t_rand (){
Time_t t;
Srand ((unsigned) time (& amp; T));
Int * * x;
X=(int) * * malloc (10 * sizeof (int *));//here you opened a pointer,
Int * p;
P=(int *) malloc (10 * sizeof (int));
For (int I=0; I<10; I++)
{
* (p + I)=rand () & amp; 100;
}
X=& amp; p;//here you and put the last pointer to the open & amp; P, while & amp; P this is a temporary variable, the temporary pointer variable pointing to the p this variable address
For (int I=1; I<10; I++)
{
Int * o;
O=(int *) malloc (10 * sizeof (int));
For (int j=0; J<10; J++)
{
Int temp=* (*) (x + I - 1 + j) + 1;
* (o + j)=temp;
}
* (x + I)=o;
}
Return the x;//and then put it back out, error big, suggest the pointer of the basic operation of first master, to explore its inside information,
}
CodePudding user response:
Thank you bosses finally I study a night out, please give directions to support#include
#include
#include
#include
using namespace std;
Void t_rand (int * * x, int * p).
Int main ()
{
Int * * x=NULL;
X=(int) * * malloc (20 * sizeof (int *));
Int * p=NULL;
P=(int *) malloc (10 * sizeof (int));
T_rand (x, p);
Free (x);
Free (p);
getchar();
return 0;
}
Void t_rand (int * * x, int * p)
{
Time_t t;
Srand ((unsigned) time (& amp; T));
For (int I=0; I<10; I++)
{
* (p + I)=rand () % 100;
}
* x=p;
For (int I=0; I<10; I++)
{
cout<* (* x + I) & lt; <" ";
}
cout
{
Int * g=(int *) malloc (10 * sizeof (int));
* (x + I + 1)=g;
For (int j=0; J<10; J++)
{
* (* (x + I + 1) + j)=* (*) (x + I + j) + 1;
Cout & lt; <* (* (x + I) + j) & lt; <" ";
}
cout
}
CodePudding user response:
The cross-border, modified as follows, for your reference:for (int I=0; I<20-1; I++)//for (int I=0; I<20; I++)
CodePudding user response: