The output of 1 to 20 7, or 13 can be divisible

Can be obtained within 1-200 divisible 7 or 13, the number of those on the array defined main function, and print out the number of

#include<iostream>
using namespace std;
int dev_fun(int a[])
{
 int m,count=0;
 for(int i=1;i<=200;i++)
 {
  if((i%7==0)||(i%13==0))
  {
   a[m++]=i; 
  }
 }
 return m; 
}
main()
{
 int a[45],l;
 l=dev_fun(a);
 for(int i=0;i<l;i++)
    {
  printf("%-4d",a[i]);
  if((i+1)%5 == 0)                            //使输出时每行五个数
   printf("\n");
    }
}
Published 102 original articles · won praise 93 · views 4979

Guess you like

Origin blog.csdn.net/huangziguang/article/details/104597552