全部代码
指针review
同样复健,数组得单独敲一个
#include <stdio.h>
int main()
{
int a[8] = {3, 1, 4, 1, 5, 9, 2, 6};
int *p=a;
int sigma=0;
int max=0;
int now;
int isfive=0;
int lasttwo=0;
int maxone=0;
for(int i=0;i<=7;i++){
now=*(p+i);
printf("%d ",now);
sigma+=now;
if(max<=now){
max=now;
maxone=i+1;
}
if(now==5){
isfive=555;
}
isfive++;
if(isfive==558){
lasttwo=now;
}
}
printf("\n最大值为%d,在第%d处取到\n",max,maxone);
printf("和 = %d\n", sigma);
printf("五后面的第二个元素为:%d",lasttwo);
return 0;
}