Problem1428--ZTP028 1到m之间(含m)能被7或11整除的所有整数

1428: ZTP028 1到m之间(含m)能被7或11整除的所有整数

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 101  Solved: 64
[Submit] [Status] [Web Board] [Creator:]

Description

编写函数fun,其功能是:将1到m之间(含m)能被7或11整除的所有整数放在数组a中,并通过n返回这些数的个数。例如,若传给m的值为50,则程序输出:
7 11 14 21 22 28 33 35 42 44 49
注意:部分源程序在文件PROG1.C中。
请勿改动主函数main和其它函数的任何内容,仅在函数fun的花括号中填入你编写的若干语句。
#include <stdio.h>
#define M 100
void  fun ( int  m, int *a , int *n )
{
}
int main( )
{
    int aa[M], n, k;
    int t;
    scanf("%d", &t);
    fun ( t, aa, &n );
    for ( k = 0; k < n; k++ )
        if((k+1)%20==0) printf("\n");
        else printf( "%4d", aa[k] );
    printf("\n") ;
    return 0;
}

Sample Input

50

Sample Output

   7  11  14  21  22  28  33  35  42  44  49

Source/Category