Home > Back-end >  Experts here, help me to read write wrong?
Experts here, help me to read write wrong?

Time:10-01

Written content is to use switch swap, but, no switch?
How do I look not to understand?

CodePudding user response:

The book allows you to compare, there is no switch, this is the value transfer, still should have the follow-up to the reference or pointer, then contrast exchanged, - book,

CodePudding user response:

reading carefully

CodePudding user response:

The book did not speak wrong, then looked down

CodePudding user response:

Means to express the book value passed to the parameter cannot return change the value of the
Must use Pointers, arrays, etc in the address can be implemented in the callback function of the original variables change
Can only succeed to return

CodePudding user response:

There is nothing wrong with the book,
The book give out the wrong example,
The correct is:
 
Void swap (int & amp; X, int & amp; Y) {
Int t=x;
X=y;
Y=t;
}

CodePudding user response:

reference 5 floor Ljnoit reply:
there is nothing wrong with the book,
The book give out the wrong example,
The correct is:
 
Void swap (int & amp; X, int & amp; Y) {
Int t=x;
X=y;
Y=t;
}




Void swap (int & amp; X, int & amp; Y) {
Int t=* x;
* x=* y;
* y=t;
}

CodePudding user response:

refer to 6th floor weixin_40290083 response:
Quote: refer to the fifth floor Ljnoit reply:

There is nothing wrong with the book,
The book give out the wrong example,
The correct is:
 
Void swap (int & amp; X, int & amp; Y) {
Int t=x;
X=y;
Y=t;
}




Void swap (int & amp; X, int & amp; Y) {
Int t=* x;
* x=* y;
* y=t;
}


You are wrong, you upstairs right, you can compile errors

CodePudding user response:

refer to 7th floor ggglivw response:
Quote: refer to the sixth floor weixin_40290083 response:

Quote: refer to the fifth floor Ljnoit reply:

There is nothing wrong with the book,
The book give out the wrong example,
The correct is:
 
Void swap (int & amp; X, int & amp; Y) {
Int t=x;
X=y;
Y=t;
}




Void swap (int & amp; X, int & amp; Y) {
Int t=* x;
* x=* y;
* y=t;
}


You are wrong, you upstairs right, you can compile error


CodePudding user response:


Your code and your answer is not the same
refer to 6th floor weixin_40290083 response:
Quote: refer to the fifth floor Ljnoit reply:

There is nothing wrong with the book,
The book give out the wrong example,
The correct is:
 
Void swap (int & amp; X, int & amp; Y) {
Int t=x;
X=y;
Y=t;
}




Void swap (int & amp; X, int & amp; Y) {
Int t=* x;
* x=* y;
* y=t;
}

CodePudding user response:

references 9 f ggglivw response:
Quote: refer to the eighth floor weixin_40290083 response:

Quote: refer to 7th floor ggglivw response:

Quote: refer to the sixth floor weixin_40290083 response:

Quote: refer to the fifth floor Ljnoit reply:

There is nothing wrong with the book,
The book give out the wrong example,
The correct is:
 
Void swap (int & amp; X, int & amp; Y) {
Int t=x;
X=y;
Y=t;
}




Void swap (int & amp; X, int & amp; Y) {
Int t=* x;
* x=* y;
* y=t;
}


You are wrong, you upstairs right, you can compile error







CodePudding user response:

11 references weixin_40290083 response:
Quote: references 9 f ggglivw response:

Quote: refer to the eighth floor weixin_40290083 response:

Quote: refer to 7th floor ggglivw response:

Quote: refer to the sixth floor weixin_40290083 response:

Quote: refer to the fifth floor Ljnoit reply:

There is nothing wrong with the book,
The book give out the wrong example,
The correct is:
 
Void swap (int & amp; X, int & amp; Y) {
Int t=x;
X=y;
Y=t;
}




Void swap (int & amp; X, int & amp; Y) {
Int t=* x;
* x=* y;
* y=t;
}


You are wrong, you upstairs right, you can compile error


nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related