解释一下,什么意思c语言

来源:百度知道 编辑:UC知道 时间:2024/04/30 03:55:09
#include<stdio.h>
void f(int*a)
{
int i=0;
while(a[i]<=10)
{
printf("%3d",a[i]);
i++;
}
}
void main()
{
int a[]={1,5,10,9,11,7};
f(a+1);
system("pause");
}

f函数
打印数组中小于10的数字
你给f传的参数是a+1 即起始位置是从a+1开始 即 数组中数组5开始比较
应为 f(int*a)中循环结束条件是while(a[i]<=10)
所以比较到11的时候 不满足循环条件循环结束
所以 打印出结果5 10 9