标签:out cout name nba for nbsp include code insert
1 #include <iostream> 2 using namespace std; 3 string str; 4 int de(string str) 5 { 6 int len=str.size(),t; 7 if(len==0) return 0; 8 string ss=""; 9 int l=0; 10 str+=‘@‘; 11 for(int i=1;i<=len;i++){ 12 if(str[i]!=str[i-1]){ 13 if(l==i-1) ss+=str[i-1]; 14 l=i; 15 } 16 } 17 if((t=ss.size())==len) return 0; 18 return len-t+de(ss); 19 } 20 int main() 21 { 22 int n; 23 cin>>n; 24 while(n--){ 25 cin>>str; 26 int sum=0,t; 27 int len=str.size(); 28 for(int i=0;i<=len;i++){ 29 string str2=str; 30 str2.insert(i,"A"); 31 if((t=de(str2))>sum) sum=t; 32 str2=str; 33 str2.insert(i,"B"); 34 if((t=de(str2))>sum) sum=t; 35 str2=str; 36 str2.insert(i,"C"); 37 if((t=de(str2))>sum) sum=t; 38 } 39 cout<<sum<<endl; 40 } 41 }
只有不断学习才能进步!
标签:out cout name nba for nbsp include code insert
原文地址:https://www.cnblogs.com/wenbao/p/5775132.html