(4)
#include "stdio.h"
char *f(char *p){
char *q;
for(q=p;*p;p++)
if(*p>='a' && *p<='z')
*p-=32;
return q;
}
int main(int argc,char *argv[]){
char a[]="12345abcdeXYZ';?";
printf("%s\n",a);
printf("%s\n",f(a));
return 0;
}
运行样例:
(11)
#include "stdio.h"
void f(int (*p)[5]){
int i,j,k;
for(i=0;i<5;i++)
for(j=0;j<i;j++)
k=*(*(p+i)+j),*(*(p+i)+j)=*(*(p+j)+i),*(*(p+j)+i)=k;
}
int main(int argc,char *argv[]){
int a[5][5]={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},i,j;
printf("The original matrix are as follows:\n");
for(i=0;i<5;i++){
for(j=0;j<5;printf("%3d",a[i][j++]));
printf("\n");
}
f(a);
printf("\nAfter the transpose is as follows:\n");
for(i=0;i<5;i++){
for(j=0;j<5;printf("%3d",a[i][j++]));
printf("\n");
}
return 0;
}
运行结果:
本回答被提问者和网友采纳