Programación de funciones de puntero
#Contains & amplt;
usingnamespacestd
intmain; ()
{
inta, b, c;
int*p1, *p2, *p3
inttemp
cout & amplt;& amplt;"Ingrese 3 números enteros:" <& amplt;endl
CIN >&gt;a &gt;&gt;b &gt;c;
p 1 = &a;
p2 = &b;
p3 = &
if(* p 1 & > *p2)
{
temp = * p 1;
* p 1 = * p2;
* p2 = temperatura;
}
if(*p 1 & gt; *p3)
{
temp = *p 1; /p>
* p 1 = * P3;
* p3 = temperatura
}
if(* p2 & > *p3)
{
temp=*p2
*p2=*p3
*p3=temperatura;
}
cout & amplt;& amplt;\n '
& amplt;& amplt;"Salida descendente:" & ;lt;& amplt;\n '
& amplt;& amplt;a & amplt;& amplt;\n '
& amplt;& amplt;b & amplt;& amplt;\n '
& amplt;& amplt;c & amplt;& amplt;\n ';
return0
}
Método 2: (Intercambie la dirección señalada por el puntero):
#Contiene & amplt; iostream & ampgt;
usandonamespacestd
intmain()
{
inta, b, c;
int*p1, *p2, *p3
int * temp
cout & amplt;& amplt;"Entrar 3 números enteros:" <& amplt;endl
CIN >&gt;a &gt;&gt;b &gt; &gt;c;
p 1 = &a;
p2 = &b;
p3 = &c;
if(* p 1 & gt; *p2)
{
temp = p 1;
p 1 = p2;
p2 = temperatura
}
si; (*p 1 & gt; *p3)
{
temp = p 1
p 1 = P3; p3 = temperatura
}
if(* p2 & gt; *p3)
{
temp = p2
p2 = p3
p3 = temperatura;
}
p>
cout &lt;&lt;\n '
&lt;&lt;"Salida descendente:" <&lt;\n '
<&lt;* p 1 <&lt;\n '
&lt;&lt;* p2 <&lt;\n '
& amplt; & amplt;stdio.h &gt;
#Contiene &lt;&gt;
intmain()
{
inta, b, c, *p1, *p2, *p3
Printf("Ingrese tres números enteros:");
scanf("% d%d%d ",&一,&b& ;c);
p 1 = &a;
p2 = &
p3 = &c;
Intercambio (p1, p2, P3);
printf("%d%d%d ", a, b, c)
return0
}
voidswap(int*x, int*y)
{
inttemp p>
if (* x & ampgt; *y)
{
temp = * x;
* x = * y;
p>
* y = temperatura;
}
}
voidexchange(p1, p2, p3)
{
intercambio(p1, p2
intercambiar(p1, P3);
intercambiar(p2, P3
}
);