a[minPos] = temp; }
main() {
int a[ARRSIZE],i;
printf(\
for (i=0; i
scanf(\
MaxMinExchang(a, ARRSIZE);
printf(\
for (i=0;i
printf(\
printf(\ }
5. 写一函数,能对给定的一个二维数组(3×3)进行转置(即行列互换)。
#include
#define N 3
int array[N][N];
void main()
{ void convert(int array[][3]);
int i,j;
printf(\
for (i=0;i for (j=0;j scanf(\ printf(\ for (i=0;i {for (j=0;j printf(\ printf(\ } convert(array); printf(\ for (i=0;i {for (j=0;j printf(\ printf(\ } } void convert(int array[][3]) {int i,j,t; for (i=0;i for (j=i+1;j {t=array[i][j]; array[i][j]=array[j][i]; array[j][i]=t; } } 6. 写一函数,能用“起泡法”对输入的10个字符按由小到大顺序排序。 #include #include #define N 10 char str[N]; void main() {void sort(char str[]); int i,flag; for (flag=1;flag==1;) {printf(\ scanf(\ if (strlen(str)>N) printf(\ else flag=0; } sort(str); printf(\ for (i=0;i printf(\ printf(\ } void sort(char str[]) {int i,j; char t; for(j=0;j for (i=0;(i if(str[i]>str[i+1]) {t=str[i]; str[i]=str[i+1]; str[i+1]=t; } } 7. 编写一个函数,由实参传来一个字符串,统计此字符串中字母、数字、空格和其他字符的个数。 #include int letter,digit,space,others; void main() {void count(char str[]); char text[80]; printf(\ gets(text); printf(\ puts(text); letter=0; digit=0; space=0; others=0; count(text); printf(\ } void count(char str[]) {int i; for (i=0;str[i]!='\\0';i++) if ((str[i]>='a'&& str[i]<='z')||(str[i]>='A' && str[i]<='Z')) letter++;