新手守护
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
int num=0,sum=1,k;
string s,x;
cin>>s;
for(int i=0;i<s.size();i++)
{
if(s[i]%2==1&&s[i]>='A'&&s[i]<='Z')
{
s[i]+=32;
}
if(s[i]%2==0&&s[i]>='a'&&s[i]<='z')
{
s[i]-=32;
}
}
for(int i=0;i<s.size();i++)
{
if(s[i]>='0'&&s[i]<='9')
{
k=s[i]-'0';
if(i!=0&&i-k>=0)
{
for(int j=1;j<=k;j++)
{
swap(s[i-num],s[i-sum]);
num++;
sum++;
}
num=0;
sum=1;
}
}
}
cout<<s;
return 0;
}
90分程序,哪里错了???
舒航在2018-08-12 17:20:37追加了内容
告诉我第一个测试点也行!!!
舒航在2018-11-16 21:14:12追加了内容
#include<iostream> #include<string> #include<cstring> using namespace std; int main() { int num=0,x=0,sum=1,k; string s; cin>>s; for(int i=0;i<s.size();i++) { if(s[i]%2==1&&s[i]>='A'&&s[i]<='Z') { s[i]+=32; } if(s[i]%2==0&&s[i]>='a'&&s[i]<='z') { s[i]-=32; } } for(int i=0;i<s.size();i++) { x++; if(s[i]>='0'&&s[i]<='9') { k=s[i]-'0'; if(k>s.size()) { k=s.size()-(s.size()-(x-1)); } for(int j=1;j<=k;j++) { swap(s[i-num],s[i-sum]); num++; sum++; } num=0; sum=1; } } cout<<s; return 0; }
新手天翼
1e3!f7k7!ii!lfka!jda@!lhfh1#fkh*6*5flak@2!hbb!6cf16iai4icf64l!l21cil5ag#ilga367*37klf5543kd1*ej323iich1d3ecbegk@idic#57!#32bdbj3j!ic*c#ggigc11kbal*a*e1@37gj*@f@k@*i#34#73i!ah3513@*4hlgb@2gf1e6i!di1@3@
731e!Fk!ii!LFka!JDa@!LHF16H#5FkH**FLa2k6@!H6BB!c14F6ia4iicFL2!51LciLag76#7i3L3g55a4*3kLFk1D3*32eJiic31HDecBegk7@5iDic3#2!#B3DBJJ!ic*c#ggig11ckBaL7*a*31e@gJ*@F@k7@43*3i##5i3!3a41H@*HLg26B@g1Fei!D31i@@
显示前50行,采纳,花了我40coding豆