Question B: The basic operation of the pointer (2) The following program, input 10 100 and 100 10, can output max=100 min=10, please add the complete program
#include <iostream>
using namespace Std;
int main ()
{
int *p1,*p2,t;
This program is not allowed to add new variables, the following use the new operator to allocate space, and P1, p2 respectively save their address
Enter two integers below. If there is no space allocated above, this operation refers to bribery space, which is extremely dangerous.
cin>>*p1>>*p2;
The code added below, only appears p1,p2 and T, do not appear a and b
cout<< "max=" <<*p1<< "min=" <<*p2<<endl; P1 and P2 point to large and small values, regardless of the input size
Write down the statements that release P1 and P2 to the space
return 0;
} input
Two integers
Output
Output large and small values in the specified format
Sample input
10 100
Sample output
max=100 min=10
/* *copyright (c) 2014, Yantai University School of computer *all rights reserved. * File name: Test.cpp * Yang Hanning * Completion Date: December 4, 2014 * Version number: v1.0 * * Problem Description: Compare two number of sizes with pointers * Program input: * Program output: */#include <iostream>using Namespac e std;int Main () { int *p1,*p2,a,b,t; cin>>a>>b; p1=&a; p2=&b; if (*P1<*P2) { t=*p1; *P1=*P2; *p2=t; } cout<< "max=" <<a<< "min=" <<b<<endl; return 0;}
Question B: basic operation of pointers (2)