有没有大佬帮忙看一下为什么第二题是百分之50
#include<iostream> #include<string> using namespace std; int main(){ string goal; cin>>goal; string num; cin>>strnum; int cnt = 0; for(int i = 1;i < strnum.length();i++){ cnt += goal.length() - i + 1; } //cout<<cnt<<endl; if(goal.length()<strnum.length()){ cout<<cnt<<endl; return 0; } for(int i = 0;i <= goal.length()-strnum.length();i++){ int flag = 0; for(int j = 0;j < strnum.length();j++){ if(strnum[j] == goal[i+j]) continue; if(strnum[j] > goal[i+j]){ flag = 1; break; } if(strnum[j] < goal[i+j]){ break; } } cnt += flag; } cout<<cnt<<endl; return 0; }