0 of 2 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 2 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
1、阅读程序写结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// more pointers #include <iostream> using namespace std; int main (){ int first_value = 5, second_value = 15; int * p1, * p2; p1 = &first_value; // p1 = address of firstvalue p2 = &second_value; // p2 = address of secondvalue *p1 = 10; // value pointed to by p1 = 10 *p2 = *p1; // value pointed to by p2 = value pointed to by p1 p1 = p2; // p1 = p2 (value of pointer is copied) *p1 = 20; // value pointed to by p1 = 20 cout << "first_value is " << first_value << '\n'; cout << "second_value is " << second_value << '\n'; return 0; } |
以上程序输出结果为:
first_value is
second_value is
2、阅读程序写结果:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include<iostream> using namespace std; void fun( int *a, int *b ){ int k; k = *a; *a = *b; *b = k; } int main(){ int a = 3, b = 6, *x = &a, *y = &b; fun( x, y ); cout<<a<<','<<b; } |
输出结果为: ,