dame
2023-12-30 12:48:59
发布于:广东
14阅读
0回复
0点赞
#include <iostream>
#include <string>
using namespace std;
int main(){
int T;
cin >> T;
string n = "";
for(int i = 0; i < T; i++){
n = "";
cin >> n;
int len = n.size();
bool flag = false;
if((n[len - 1] - '0') % 2 == 0){
cout << 0 << endl;
}else if((n[0] - '0') % 2 == 0){
cout << 1 << endl;
}else{
for(int j = 1; j < len - 1; j++){
if((n[j] - '0') % 2 == 0){
flag = true;
break;
}
}
if(flag == true){
cout << 2 << endl;
}else{
cout << -1 << endl;
}
}
}
return 0;
}
这里空空如也
有帮助,赞一个