初学C语言,求帮助。。
编写函数fun,它的功能是:求出1到100之内能被7或者11整除,但不能同时被7和11整除的所有整数,并将他们放在a所指的数组中,通过n返回这些数的个数。
unsigned fun( unsigned a[] ) { unsigned n = 0; for( unsigned i=7; i<=100; ) { a[n++] = i; unsigned a = (i/7+1)*7; unsigned b = (i/11+1)*11; if( a < b ) i = a; else if( a > b ) i = b; else i = a + 7; } return n; } #include <stdio.h> int main() { unsigned a[100]; unsigned n = fun( a ); for( unsigned i=0; i<n; ++i ) printf( "%u, ", a[i] ); return 0; }