1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
// Example program
#include <iostream>
#include <string>
using namespace std;
void flipH(char source[], char dest[], int row, int coln);
int main()
{
char source[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t'};
char dest[]={};
flipH(source,dest,4,5);
cout<<dest[0]<<" "<<dest[1]<<" "<<dest[2]<<" "<<dest[3]<<" "<<dest[4]<<" "<<endl;
cout<<dest[5]<<" "<<dest[6]<<" "<<dest[7]<<" "<<dest[8]<<" "<<dest[9]<<" "<<endl;
cout<<dest[10]<<" "<<dest[11]<<" "<<dest[12]<<" "<<dest[13]<<" "<<dest[14]<<" "<<endl;
cout<<dest[15]<<" "<<dest[16]<<" "<<dest[17]<<" "<<dest[18]<<" "<<dest[19]<<" "<<endl;
return 0;
}
void flipH(char source[], char dest[], int row, int coln){
int count=0;
for(int i = 0; i < row; i++){
for(int j = 0; j < coln; j++){
dest[count] = source[(row-1-i)*coln + j];
count++;
}
}
}
|