#A1018. 指针方式的最大数筛选
指针方式的最大数筛选
背景
有言云,前人栽树,后人乘凉。
总之,偷懒的LesteM决定剽窃借鉴他人的智慧,出一道指针题目
Description
写一个函数,函数中用指针变量x指向数组a,n代表该数组a的长度,要求返回数组中的最大值。
Format
Input
两行,第一行为一个数字n,代表数组的长度 第二行为n,代表数组中每个位置对应数字的大小
Output
数组中的最大数
Samples
5
1 5 2 4 3
5
Limitation
1s, 1024KiB for each test case.
按以下格式写一个函数。
#include<stdio.h>
int *fun(int *x,int n)
{
//自填
}
main()
{
int n;
scanf("%d",&n);
int a[n],*p,i;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
p=fun(a,n);
printf("%d\n",*p);
}