} 6-7
#include
{ int a[15][15],i,j,k,p,n; p=1;
while(p==1)
{printf(\ scanf(\
if ((n!=0) && (n<=15) && (n%2!=0)) p=0; }
for (i=1;i<=n;i++) for (j=1;j<=n;j++) a[i][j]=0; j=n/2+1; a[1][j]=1;
for (k=2;k<=n*n;k++) {i=i-1; j=j+1;
if ((i<1) && (j>n)) {i=i+2; j=j-1; } else
{if (i<1) i=n; if (j>n) j=1; }
if (a[i][j]==0) a[i][j]=k; else
{i=i+2; j=j-1; a[i][j]=k; } }
for (i=1;i<=n;i++) {for (j=1;j<=n;j++)
printf(\ printf(\ } return 0; }
6-8
#include
#define M 5 /* 数组为4行5列 */ int main() {
int i,j,k,a[N][M],max,maxj,flag; printf(\
for (i=0;i {max=a[i][0]; /* 开始时假设a[i][0]最大 */ maxj=0; /* 将列号0赋给maxj保存 */ for (j=0;j flag=1; /* 先假设是鞍点,以flag为1代表 */ for (k=0;k if(flag) /* 如果flag1为1表示是鞍点 */ {printf(\ /* 输出鞍点的值和所在行列号 */ break; } } if(!flag) /* 如果flag为0表示鞍点不存在 */ printf(\ return 0; } 6-9 #include { int i,number,top,bott,mid,loca,a[N],flag=1,sign; char c; printf(\ scanf(\ i=1; while(i {scanf(\ if (a[i]>=a[i-1]) i++; else printf(\ } printf(\ for (i=0;i {printf(\ scanf(\ sign=0; top=0; //top是查找区间的起始位置 bott=N-1; //bott是查找区间的最末位置 printf(\ sign=1; } else if (number top=mid+1; } if(!sign||loca==-1) printf(\ printf(\ scanf(\ if (c=='N'||c=='n') flag=0; } return 0; } 6-10 #include {int i,j,upp,low,dig,spa,oth; char text[3][80]; upp=low=dig=spa=oth=0; for (i=0;i<3;i++) { printf(\ gets(text[i]); for (j=0;j<80 && text[i][j]!='\\0';j++) {if (text[i][j]>='A'&& text[i][j]<='Z') upp++; else if (text[i][j]>='a' && text[i][j]<='z') low++; else if (text[i][j]>='0' && text[i][j]<='9') dig++; else if (text[i][j]==' ') spa++; else oth++; } } printf(\ printf(\ printf(\ : %d\\n\ printf(\ : %d\\n\ printf(\ : %d\\n\ return 0; } 6-12a-c #include char ch[80],tran[80]; printf(\ gets(ch); printf(\ :%s\ j=0; while (ch[j]!='\\0') { if ((ch[j]>='A') && (ch[j]<='Z')) tran[j]=155-ch[j];