注意末尾不要留逗号
2024-11-09 09:52:00
发布于:广东
4阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
bool f(int x)
{
    while (x>0)
    {
        if (x%10%2==1)
            return false;
        x/=10;
    }
    return true;
}
int main()
{
    int n,m;
    cin >> n >> m;
    string s="";
    for (;n<=m;n++)
    {
        if (f(n))
        {
            s+=to_string(n);
            s+=',';
        }
    }
    if (!s.empty())
        s=s.substr(0,s.size()-1);
    cout << s;
	return 0;
}
这里空空如也





有帮助,赞一个