分析问题
遍历所有两位,将数位上含有2的数字从小到大输出
建立模型
初始化 i 等于 10
当 i 小于 100 时
如果 i 的最后一位是2 或者 i的第1位是2
输出 i
i 增加 1
编写代码
#include <bits/stdc++.h>
using namespace std;
int main(){
int i=10;
while(i<=100){
if(i%10==2 || i/10==2)
cout<<i<<endl;
i++;
}
return 0;
}