Sicily 1036. Crypto Columns

来源:互联网 发布:新华书店淘宝旗舰店 编辑:程序博客网 时间:2024/06/05 18:35
#include <iostream>#include <string>#include <algorithm>using namespace std;char ch[11][11];int arr[100];char ch1[11][11];int main(){string str;while(cin >> str&&str!="THEEND"){int len=str.length();string st;cin >> st;int len1=st.length();int high=len1/len,m=0;for(int k=0; k < len; k++)for(int i=0; i < high; i++)ch[i][k]=st[m++];/*for(int k=0; k < len; k++){for(int i=0; i < high; i++)cout << ch[i][k];cout << endl;}*/string str1=str;int count=0;for(int i=0; i < len; i++)for(int j=i; j < len; j++){if(str1[j]<str1[i]) swap(str1[i],str1[j]);}//cout << str1 << endl;for(int i=0; i < len; i++){for(int j=0; j < len; j++){if(str[i]==str1[j]){arr[count++]=j+1;str1[j]='*';break;}}}/*for(int i=0; i < len; i++)cout << arr[i] << " ";cout << endl;*/count=0;for(int i=0; i < len; i++){for(int k=0; k < high; k++){ch1[k][count]=ch[k][arr[i]-1];}count++;}for(int i=0; i < high; i++)for(int k=0; k < len; k++)cout << ch1[i][k];cout << endl;}}

0 0
原创粉丝点击