maneedhar
10/11/2018 - 6:40 PM

String manipulation

#include <bits/stdc++.h>
using namespace std;

string inc (string s){
    vector<int> v;
	for (int i=0; i<s.size(); i++){
	    v.push_back((s[i]-'0')+1);
	}
	string x;
	for (int i=0; i<v.size(); i++){
        x.push_back(v[i]+'0');
    }
    return x;
}

string dec (string s){
    vector<int> v;
	for (int i=0; i<s.size(); i++){
	    v.push_back((s[i]-'0')-1);
	}
	string y;
	for (int i=0; i<v.size(); i++){
        y.push_back(v[i]+'0');
    }
    return y;
}

int main() {
    int t;
    cin>>t;
    while (t--){
        string s;
	    cin>>s;
	        string x = inc (s);
	        cout<<x<<endl;
	        string y = dec (s);
	        cout<<y<<endl;
    }
	return 0;
}