Solution in c++
#include <iostream> using namespace std; int main() { string c; cin>>c; int cs=c.size(); int poss=-1; for(int i=0;i<cs;i++) { if((c[i]-'0')%2==0) { poss=i; if(c[cs-1]>c[i]) { swap(c[i],c[cs-1]); cout<<c; return 0; } } } if(poss==-1) { cout<<-1<<"\n"; return 0; } else { swap(c[poss],c[cs-1]); cout<<c; return 0; } return 0; }
0 التعليقات:
إرسال تعليق