#include
using std::cout;
using std::cin;
using std::endl;
int main()
{
int n, m, counter = 0;
cout << "Enter n: ";<br> cin >> n;
cout << "Enter m: ";<br> cin >> m;
if(n >= m)
{
cout << "Invalid value" << endl;<br> }
else
{
while(n <= m)<br> {
if(n % 4 == 0)
{
counter++;
}
n++;
}
}
cout << counter << " value" << (counter != 1 ? "s" : "") << endl;<br>
cin.get();
return 0;
}
Вывод:
Enter n: 2000
Enter m: 2012
4 values
На Паскале:
program test;
var n, m, counter: integer;
begin
write('Enter n: ');
readln(n);
write('Enter m: ');
readln(m);
counter := 0;
while n <= m do<br> begin
if n mod 4=0 then
counter := counter + 1;
n := n + 1;
end;
writeln(counter, ' values');
readln();
end.