#include <iostream> #include <string> using namespace std; int main() { int n;cin>>n; while (n--) { string s; cin>>s; for (int i=0; i<s.size(); i++) { if (s[i]>='0'&&s[i]<='9') { cout<<i+1<<" "; } } cout<<endl; } } // 64 位输出请用 printf("%lld")
#include <iostream> #include <string> using namespace std; int main() { int n;cin>>n; while (n--) { string s; cin>>s; for (int i=0; i<s.size(); i++) { if (s[i]>='0'&&s[i]<='9') { cout<<i+1<<" "; } } cout<<endl; } } // 64 位输出请用 printf("%lld")