//
// main.cpp
// WERTY
//
// Created by Panks on 27/05/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define ull unsigned long long
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,n) FOR(i,0,n-1)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REPD(i,n) FOR(i,n-1,0)
#define testcase(t) int t;scanf("%d",&t);while(t--)
#define s(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define p(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define ps(x) printf("%s",x)
#define pn(x) printf("%d\n",x)
#define pln(x) printf("%lld\n",x)
#define psn(x) printf("%s\n",x)
#define all(c) c.begin(),c.end()
string row1="`1234567890-=", row2="QWERTYUIOP[]\?", row3="ASDFGHJKL;'", row4="ZXCVBNM,./<";
void replaceit(char a);
void replaceit(char a){
if (a==' ') {
cout<<" ";
}
string::iterator pos;
if(count(row1.begin(), row1.end(), a)){
pos=find(all(row1), a);
pos--;
cout<<*pos;
}else if(count(row2.begin(), row2.end(), a)){
pos=find(all(row2), a);
pos--;
cout<<*pos;
}else if(count(row3.begin(), row3.end(), a)){
pos=find(all(row3), a);
pos--;
cout<<*pos;
}else if(count(row4.begin(), row4.end(), a)){
pos=find(all(row4), a);
pos--;
cout<<*pos;
}
}
int main (int argc, const char * argv[])
{
string input;
while(getline(cin, input)){
for_each(input.begin(), input.end(), replaceit);
cout<<endl;
}
}
Saturday, June 2, 2012
10082 - WERTYU
You can combine all the arrays in one and can do a lot better :) , I was just rushing through when I coded these.
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment