输入两个整数a,b计算a和b之间能被4或6整除的数的个数
#include<stdio.h>
int main()
{
int a,b;
int count = 0;
scanf("%d %d",&a,&b);
for(int i = a;i <= b;i++){
if(i % 4 == 0 || i % 6 == 0){
count++;
//printf("%d ",i);
}
}
printf("%d ",count);
return 0;
}
public string CheckNums(int a, int b)
{
string result = "";
for (int i = a; i <= b; i++)
{
if (i % 4 == 0 && i % 6 == 0)
{
if (result == "")
result = i.ToString();
else
result += "," + i.ToString();
}
}
}
int main()
{
int a, b, cnt = 0;
cin >> a >> b;
while (a <= b)
{
if (a % 4 == 0 && a % 6 == 0)
cnt++;
a++;
}
cout << cnt << endl;
return 0;
}