#include <stdio.h>
#include <stdlib.h>
int main()
{
int n = 0, i = 0;
int max=0,rmax=0;
printf("请输入元素个数:");
scanf("%d", &n);
int *p1 = (int *)malloc(sizeof(int)*n);
printf("请输入整型元素以空格隔开回车结束:");
do
{
scanf("%d", p1+i);
i++;
} while (getchar() != '\n');
int *p2 = p1;
for (i = 0; i < n; i++)
{
if (*p2 > max)
{
*p2 = *p2 + max;
max = *p2 - max;
*p2 = *p2 - max;
}
if (*p2 > rmax)
{
*p2 = *p2 + rmax;
rmax = *p2 - rmax;
}
p2++;
}
printf("所输入元素中第二大的数为:%d", rmax);
free(p1);
while (1);
return 0;
}