C语言编写找出1-100之间能被7或11整除的所有整数

来源:百度知道 编辑:UC知道 时间:2024/07/04 11:00:13
编写找出1-100之间能被7或11整除的所有整数,存放在数组a中,并统计其个数。要求以每行排列5个数据的形式输出a数组中的数据。

#include <stdio.h>
#include <stdlib.h>

int
main( void )
{
int i;
int j = 0;
int t = 0;
int a[100];

for( i = 0; i < 100; i++ )
if( ( i % 7 == 0 ) || ( i % 11 ) == 0 )
{
a[j] = i;
j++;
}

for( i = 0; i < j; i++ )
{
printf( "%d ", a[i] );
t++;
if( t % 5 == 0 )
printf( "\n" );
}

return EXIT_SUCCESS;
}

竟然一分的诚意都没有。。。早知就不写了。

#include <stdio.h>
#define N 50
void main()
{
int find(int *p,int n);
int array[N]={0};
int *parray;
int count=0;
int key=0;
int i;
parray=array;
key=find(parray,100);
printf("These numbers are :\n");
for(i=0;i<key;i++)
{
printf("%d ",*(parray+i));
count++;
if(count==5)
{
printf("\n&quo