1006.Do the Untwist
来源:互联网 发布:网络安全法逐条解读 编辑:程序博客网 时间:2024/05/16 13:43
题目大意就是根据字母的序号和给出的公式将密码翻译过来。
#include <stdio.h>#include <string.h>int main ( ){ int ciphercode[ 70 ] , plaincode[ 70 ] ; char plaintext[ 70 ] , ciphertext[ 70 ] ; int K ; while ( scanf("%d",&K ) , K ) { scanf("%s",ciphertext ); int i , n ; n = strlen( ciphertext ) ; for ( i = 0 ; i < n ; i ++ ) { if ( ciphertext[ i ] == '.' ) ciphercode[ i ] = 27; if ( ciphertext[ i ] == '_' ) ciphercode[ i ] = 0; else if ( ciphertext[ i ] >= 'a' && ciphertext[ i ] <= 'z' ) ciphercode[ i ] = ciphertext[ i ] - 'a' + 1 ; } for ( i = 0 ; i < n ; i ++ ) plaincode[ ( i*K) % n ] = ( ( ciphercode[ i ] + i ) % 28 ) ; for ( i = 0 ; i < n ; i ++ ) { if ( plaincode[ i ] == 27 ) plaintext[ i ] = '.' ; if ( plaincode[ i ] == 0 ) plaintext[ i ] = '_' ; else if ( plaincode[ i ] > 0 && plaincode[ i ] < 27 ) plaintext[ i ] = plaincode[ i ] + 'a' - 1 ; } for ( i = 0 ; i < n ; i ++ ) printf( "%c", plaintext[ i ] ); printf("\n"); } return 0;}
整体思路是很清晰的,在公式的转换那里一直卡壳。。。根据网上的代码改过来了。。。
阅读全文
0 0
- 1006.Do the Untwist
- Do the Untwist (1006)
- Do the Untwist
- 1006 Do the Untwist
- Do the Untwist
- ZOJ1006 Do the Untwist
- Do the Untwist
- Do the Untwist
- zoj1006-Do the Untwist
- C++ --Do the Untwist
- POJ1317 Do the Untwist
- ZOJ1006-Do the Untwist
- Do the Untwist
- 1006 Do the Untwist
- ACM-1006-Do the Untwist
- ZOJ-1006-Do the Untwist
- HDU 1129 Do the Untwist
- zoj 1006 Do the Untwist
- 【每天积累一点点】BottomNavigationView使用教程
- SQLServer配置管理器 SQL Sever服务——远程过程调用失败(0x800706be)
- 第一次
- 利用哈夫曼编码压缩文件
- AVL树的学习笔记
- 1006.Do the Untwist
- .Net面试经历(1)
- eclipse导入项目后打开html文件乱码问题
- Activity生命周期
- qemu-nbd 挂载
- CodeForces
- Java集合框架
- Systemtap简介
- Kotlin 学习之数据类型