noip2012提高day1T1
大概就是把题目中的表存进去然后就没了qaq
1 #include2 #include 3 #include 4 using namespace std; 5 char s[30][30]; 6 char k[110], m[1010]; 7 int lenm, lenk; 8 bool flam[1010]; 9 void init() {10 for(int i = 1; i <= lenk; i++) {11 int mid = (int)(k[i]);12 if(mid>=65&&mid<=90) k[i] += 32;13 }14 for(int i = 1; i <= lenm; i++) {15 int mid = (int)(m[i]);16 if(mid>=65&&mid<=90) {17 flam[i] = 1; 18 m[i] += 32;19 }20 }21 }22 void get_list() {23 for(int i = 1; i <= 26; i++) {24 char c = 'a'+i-1;25 s[i][1] = c;26 for(int j = 2; j <= 26; j++) {27 s[i][j] = c+1;28 c = s[i][j];29 if(c >= 'z') c -= 26;30 }31 }32 }33 void work() {34 int mm;35 for(int i = 1; i <= lenm; i++) {36 mm = i % lenk;37 if(mm==0) mm = lenk;38 for(int j = 1; j <= 26; j++) {39 if(s[(int)(k[mm]-96)][j] == m[i]) {40 if(flam[i]) cout<<(char)(j+64);41 else cout<<(char)(j+96);42 }43 }44 } 45 }46 int main() {47 get_list();48 scanf("%s%s",k+1, m+1);49 lenm = strlen(m+1);50 lenk = strlen(k+1);51 init();//刚开始把它写在了上两行前面qaq然后就出现了密文中大写字母明文无输出的情况orz52 work();53 return 0;54 }
说好了昨天刷dp结果把洛谷上所有noip真题入门难度的做完了QAQ
今天是不是该普及-惹qaq