作业三 4,5

二,代码

#include<stdio.h>
#define N 10
main()
{int  fun (int *p);
int a[10]={1,2,3,4,5,6,7,8,9,10};
int *p ;
    p=a;
    fun(a);
    
}
    
int fun(int *p) 
{int i;
for(i=0;i<N;i++)
printf("%d",*p+i);
} 

 结果:

12345678910
--------------------------------
Process exited after 0.1311 seconds with return value 0
请按任意键继续. . .

总结:

1,我一开始的看到题目的思路是像上次一样,用getchar输出来,后来经过查找,getchar只能输出字符所以这条思路行不通。

2,后来我通过书中的查找知道了,可以用define来从前面定义整数然后这样在for循环里就不用出现数字10了!!!

3,要善于查找和学习。

码云:281621575@qq.com

 

posted @ 2017-04-05 07:21  孙鸣阳  阅读(96)  评论(0编辑  收藏  举报