qfedu-basic-level/day7/d8.cpp

21 lines
320 B
C++
Raw Permalink Normal View History

2023-06-21 14:30:56 +08:00
// 输入一个数,输出小于这个数所有偶数
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "请输入一个数:";
cin >> n;
int i = 0;
while (i < n)
{
if (i % 2 == 0)
cout << i << "\t";
i++;
}
cout << endl;
return 0;
}