#UVa:458-The Decoder

灆洢 2011-11-25 00:49:34

利用ASCII碼找出Sample Input和Sample Output相差的k值,將輸入的每個字都以此k值做加減即可得解。

C++(0.172)

/*******************************************************/
/* UVa 458 The Decoder                                 */
/* Author: Maplewing [at] knightzone.studio            */
/* Version: 2011/11/25                                 */
/*******************************************************/
#include<iostream>
#include<cstdio>
using namespace std;

int main(){
  const int K = (int)('*'-'1');
  string s;
  while( getline( cin, s ) ){
    for( int i = 0 ; i < s.length() ; i++ )
      printf( "%c", s[i]+K );
    printf( "\n" );
  }
  return 0;
}

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料