先放程序
#include<iostream>
using namespace std;
int main(){
int ans = 0;
string s;
cin>>s;
int n = s.length();
int i = 0;
int lit = 0;
while(i < n){
if(s[i] >= 'A' && s[i] <= 'Z'){
if((i + ans) % 4 != 0){
ans += 3 - lit;
cout<<ans<<' '<<i<<endl;
}
lit = 0;
}
else{
lit++;
}
i++;
}
cout<<ans;
return 0;
}
思路:
lit是当前指令参数数量。
每次如果位置不对,就把4(固定数量)减去参数数量再减去1(指令自己也占位置),简化一下就是3 - lit。
自己没看出来错误,求助。
(7个点3WA)