SRM 147 DIV 2 (250)

Programming/SRM Practice 2009. 5. 27. 00:48
SRM 147 DIV 2 (250)
문제 요약 : 주어진 문장을 주어진 수만큼 shift한 후
결과 값을 반환하라.

#include <iostream>

using namespace std;

class CCipher

{

public:

  string decode(string cipherText, int shift);

};

 

string CCipher::decode(string cipherText, int shift)

{

  string res = "";


  
for(int i = 0 ; cipherText[i] ; i++)

    if(cipherText[i] - shift < 'A')  res += cipherText[i] + 26 - shift;

    else  res += cipherText[i] - shift;


  
return res;
}

'Programming > SRM Practice' 카테고리의 다른 글

SRM 148 DIV 2 (250)  (0) 2009.05.27
SRM 146 DIV 2 (250)  (0) 2009.05.27
SRM 370 DIV 2 (500)  (0) 2009.05.26
SRM 370 DIV 2 (250)  (0) 2009.05.26
SRM 205 DIV 2 (250)  (0) 2009.05.26
: