It's showing "Time Limit Exceeded" error.....how can I solve it?

#include
#include <bits/stdc++.h>

using namespace std;
string func(string l, char array[]){
int n = l.length();
strcpy(array, l.c_str());
return array;
}
int main()
{
int t;
cin>>t;
while(t–){
int n;
cin>>n;
string s;
cin>>s;
char array[n];
func(s,array);
int i;
for(i=0;i<n;i+2){
char g = array[i];
array[i] = array[i+1];
array[i+1] = g;
}

        switch(array[i]){
           case 'a':
            array[i]= 'z';
            break;
            case 'b':
            array[i]= 'y';
            break;
            case 'c':
            array[i]= 'x';
            break;
            case 'z':
            array[i]= 'a';
            break;
            }

    for(i=0;i<n;++i){
        cout<<array[i];
    }
    cout<<endl;
}
return 0;

}

//