| ||||||||||
| 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 | |||||||||
1107怎么就不过呢,请哪位大牛指教一下啊?#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int k[3],i,j,na,nb,nc;
int aa,bb,cc;
char str[81],a[81],b[81],c[81];
while(1){
cin>>k[0]>>k[1]>>k[2];
if((k[0]||k[1]||k[2])==0)break;
cin>>str;
na=0;nb=0;nc=0;
for(i=0;str[i]!='\0';i++){//找到各集团
if(str[i]>='a'&&str[i]<='i'){
a[na]=str[i];
na++;
str[i]='1';
}
else if(str[i]>='j'&&str[i]<='r'){
b[nb]=str[i];
str[i]='2';
nb++;
}
else{
c[nc]=str[i];
str[i]='3';
nc++;
}
}
a[na]='\0';b[nb]='\0';c[nc]='\0';
aa=na;bb=nb;cc=nc;
na=0;nb=0;nc=0;
for(i=0;str[i]!='\0';i++){//更改位置
if(str[i]=='1'){
str[i]=a[(++na+aa-k[0]-1)%aa];
}
else if(str[i]=='2'){
str[i]=b[(++nb+bb-k[1]-1)%bb];
}
else if(str[i]=='3'){
str[i]=c[(++nc+cc-k[2]-1)%cc];
}
}
cout<<str<<endl;
}
system("PAUSE");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator