Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:总算AC了,改错改了半天,冒着被大家骂的危险,把代码贴在这里!In Reply To:总算AC了,改错改了半天,冒着被大家骂的危险,把代码贴在这里! Posted by:810974380 at 2009-07-29 17:44:00 > > > 互相学习学习!欢迎交流! > > #include<iostream> > #include<cstring> > using namespace std; > int main() > { int n,length,m,b[210];char c,str[210]; > while(cin>>n) > {if(n==0) break; > cin>>str; > length=strlen(str); > m=length/n; > for(int w=0;w<length;w++) > b[w]=0; > for(int i=0;i<length;i++) > if(i/n%2!=0&&b[i]==0) > {c=str[i];str[i]=str[(n-i%n-1-i%n+i)];str[(n-i%n-1-i%n+i)]=c; > b[i]=1;b[(n-i%n-1-i%n+i)]=1; > } > for(int j=0;j<n;j++) > for(int k=0;k<length;k++) > if(k%n==j) cout<<str[k]; > cout<<endl; > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator