标签:style blog class code c java
#include<iostream> #include<string.h> using namespace std; const int N=1000; char c[N]; int len; void swap(char &a,char &b) { //a=a^b; //b=a^b; //a=a^b; char c=a; a=b; b=c; } void display() { for(int i=0;i<len;i++) { cout<<c[i]; } } int main() { int len2; cin>>len2; while(len2--) { cin>>c; len=strlen(c); cout<<"长度为"<<len<<endl; int beg=0; int end=len-1; int cur=0; while(cur<=end) { if(c[cur]==‘R‘) { swap(c[cur],c[beg]); // cout<<"swapR"<<cur<<"---and--"<<beg<<endl; beg++; cur++; } else if(c[cur]==‘W‘) { cur++; } else { swap(c[cur],c[end]); // cout<<"swapB"<<cur<<"---and--"<<end<<endl; end--; } cout<<"正在进行"<<endl; } display(); cout<<endl; } system("pause"); return 0; }
nyoj 数的二进制中1的个数,布布扣,bubuko.com
标签:style blog class code c java
原文地址:http://www.cnblogs.com/hansongjiang/p/3734497.html