70分(5,7,9)求调!!!

P1098 [NOIP2007 提高组] 字符串的展开

啊,homo特有的改完多WA两个点
by zzhhyy1234 @ 2024-08-24 09:27:36


算了看我的代码吧 ```cpp #include<bits/stdc++.h> using namespace std; int main() { int p1,p2,p3; string s; cin>>p1>>p2>>p3; cin>>s; int l=s.length(); for(int i=0;i<l;i++){ if(s[i]!='-') cout<<s[i]; else{ if(s[i-1]=='-'||s[i+1]=='-'||i==l-1||i==0||s[i-1]>=s[i+1]||(isalpha(s[i-1])&&isdigit(s[i+1]))||(isalpha(s[i+1])&&isdigit(s[i-1]))){ cout<<'-'; continue; } if(s[i-1]+1==s[i+1]) continue; if(p3==1){ for(char j=s[i-1]+1;j<=s[i+1]-1;j++){ for(int k=1;k<=p2;k++){ if(isalpha(s[i-1])){ if(p1==1) cout<<char(j); else if(p1==2) cout<<char(j-32); else cout<<'*'; } else{ if(p1==3) cout<<'*'; else cout<<j; } } } } else{ for(char j=s[i+1]-1;j>=s[i-1]+1;j--){ for(int k=1;k<=p2;k++){ if(isalpha(s[i-1])){ if(p1==1) cout<<char(j); else if(p1==2) cout<<char(j-32); else cout<<'*'; } else{ if(p1==3) cout<<'*'; else cout<<char(j); } } } } } } return 0; } ```
by zzhhyy1234 @ 2024-08-24 09:28:25


声明一下,我的是C艹代码(悲
by zzhhyy1234 @ 2024-08-24 09:29:54


string可以理解为升级版的char数组 cout约等于printf (看样子你应该是学C的,所以解释了一下)
by zzhhyy1234 @ 2024-08-24 09:32:36


@[zzhhyy1234](/user/1367086) @[zzhhyy1234](/user/1367086) 感谢!!!!!!!!!!!!!
by LabmemNo_012LzTopic @ 2024-08-26 09:20:38


上一页 |