1、
#include <stdio.h> void rev(char x[][128], int n) { int i; for(i = 0; i < n; i++) { int len = 0; while(x[i][len]) len++; int j = 0; while(x[i][j]) putchar(x[i][len - 1 - j++]); putchar(' '); } } int main(void) { char str[][128] = {"SEC","ABC"}; rev(str, 2); return 0; }
2、
#include <stdio.h> int prin(char x[][128], int n) { int i; for(i = 0; i < n; i++) { int j = 0; while(x[i][j]) j++; while(j--) putchar(x[i][j]); putchar(' '); } } int main(void) { char str[][128] = {"abcd", "xyzop"}; prin(str, 2); return 0; }
3、
#include <stdio.h> void pri(char x[][128], int n) { int i; char tmp[n][128]; for(i = 0; i < n; i++) { int len = 0; while(x[i][len]) len++; int j = 0; while(x[i][j]) { tmp[i][j] = x[i][len - 1 - j]; j++; } } for(i = 0; i < n; i++) { int k = 0; while(x[i][k]) { x[i][k] = tmp[i][k]; k++; } } for(i = 0; i < n; i++) { printf("%s ", x[i]); } } int main(void) { char str[][128] = {"abcd", "xyz"}; pri(str, 2); return 0; }
4、
#include <stdio.h> void prin(char x[][128], int n) { int i, j; for(i = 0; i < n; i++) { int len = 0; while(x[i][len]) len++; for(j = 0; j < len / 2; j++) { int tmp = x[i][j]; x[i][j] = x[i][len - 1 - j]; x[i][len - 1 - j] = tmp; } } for(i = 0; i < n; i++) { printf("%s ", x[i]); } } int main(void) { char str[][128] = {"abcd","mnop","123456"}; prin(str, 3); return 0; }
5、
#include <stdio.h> void print(char x[][128], int n) { int i; char tmp[n][128]; for(i = 0; i < n; i++) { int len = 0; while(x[i][len]) len++; int j = 0; for(j = 0; j < len; j++) { tmp[i][j] = x[i][len - 1 - j]; } for(j = 0; j < len; j++) { x[i][j] = tmp[i][j]; } } for(i = 0; i < n; i++) { printf("%s ", x[i]); } } int main(void) { char str[][128] = {"abcde", "mnopq", "12345678"}; print(str, 3); return 0; }