情况还不错,就是参与的人太少,新手也不来尝试,只是部分达到了我的初衷,继续等等看,可以说这道题有很多方法,我想的只有两种(水平有限),基于楼上的各位意见,方法又增加了两种,希望有更多的人参与进来

免费赠送河蟹一只
程序代码://给一个n*n矩阵,实现矩阵90°转置
#include<stdio.h>
int main()
{
int n,i,j,a[100][100],temp=1;
printf("输入矩阵的阶数:");
scanf("%d",&n);
for(i=0;i<n;i++)//自动完成矩阵输入
for(j=0;j<n;j++)
{
a[i][j]=temp++;
}
printf("原矩阵为:\n");
for(i=0;i<n;i++)//输出原矩阵
{
for(j=0;j<n;j++)
{
printf("%-3d",a[i][j]);
}
printf("\n");
}
printf("90°转置后:\n");
for(j=n-1;j>=0;j--)//输出转置后的矩阵
{
for(i=0;i<n;i++)
{
printf("%-3d",a[i][j]);
}
printf("\n");
}
return 0;
}

程序代码:#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define getValue(array, width, rows, cols) (*((array) + (rows) * (width) + (cols)))
#define setValue(array, width, rows, cols, value) (*((array) + (rows) * (width) + (cols)) = (value))
int main(void)
{
int * pRect, * pTmp;
int rows, cols;
int i, j, tmp;
scanf("%u", &rows);
cols = rows;
/* or
scanf("%u", &cols);
rows = cols;
*/
pRect = (int *)calloc(rows * cols, sizeof(int));
pTmp = (int *)calloc(rows * cols, sizeof(int));
for(i = 0; i < rows; i++) {
for(j = 0; j < cols; j++) {
scanf("%d", &tmp);
setValue(pRect, cols, i, j, tmp);
}
}
printf("\n");
for(i = 0; i < rows; i++)
for(j = 0; j < cols; j++)
setValue(pTmp, cols, rows - 1 - j, i, getValue(pRect, cols, i, j));
memcpy(pRect, pTmp, sizeof(int) * cols * rows);
for(i = 0; i < cols; i++)
for(j = 0; j < rows || !printf("\n"); j++)
printf("%d ", getValue(pRect, cols, i, j));
free(pRect);
free(pTmp);
return 0;
}

程序代码:#include<stdio.h>
#define MAX 100
void main()
{
int a[MAX][MAX],n;
int i,j,k=1;
scanf("%d",&n);
printf("转置前:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=k++;
/*
scanf("%d",&a[i][j]);
*/
printf("%4d",a[i][j]);
}
printf("\n");
}
printf("转置后:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%4d",a[j][n-i-1]);
}
printf("\n");
}
}

程序代码:#include<stdio.h>
#define MAX 100
void func(int a[][MAX],int x1,int y1,int x2,int y2)
{
int j,temp,k=0;
if(x1>=x2)
return;
for(j=0;j<x2-x1;j++)
{
temp=a[x1+j][y1];
a[x1+j][y1]=a[x1][y2-j];
a[x1][y2-j]=a[x2-j][y2];
a[x2-j][y2]=a[x2][y1+j];
a[x2][y1+j]=temp;
}
func(a,x1+1,y1+1,x2-1,y2-1);
}
void main()
{
int a[MAX][MAX],n;
int i,j,k=1;
scanf("%d",&n);
printf("转置前:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
a[i][j]=k++;
/*
scanf("%d",&a[i][j]);
*/
printf("%4d",a[i][j]);
}
printf("\n");
}
printf("转置后:\n");
func(a,0,0,n-1,n-1);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%4d",a[i][j]);
}
printf("\n");
}
}