| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
 大量收QQ微信精准粉/交友粉，非诚勿扰 千里之行 始于足下

已结贴   问题点数：5  回复次数：5

#include <stdio.h>
int main(void)
{
int num[3][3];
int i = 0, j = 0;
void zhuanzhi(int a[][3]);
printf("Please input nine numbers:\n");
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
printf("num[%d][%d] = ", i, j);
scanf("%d", &num[i][j]);
}
}
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
printf("%5d", num[i][j]);
}
printf("\n");
}
printf("\n");
zhuanzhi(num);
return 0;
}

void zhuanzhi(int a[][3])   /*定义转置数组函数*/
{
int i, j, temp;
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
temp = a[i][j];
a[i][j] = a[j][i];
a[j][i] = temp;
}
}
for (i = 0; i <= 2; i++)
{
for (j = 0; j <= 2; j++)
{
printf("%5d", a[k][h]);
}
printf("\n");
}
}

得分:0

得分:2

得分:3

for (i = 0; i <= 2; i++)
{
for (j = i; j <= 2; j++)
{
temp = a[i][j];
a[i][j] = a[j][i];
a[j][i] = temp;
}
}

得分:0

得分:0

• 6
• 1/1页
• 1

Powered by Discuz, Processed in 0.021460 second(s), 7 queries.
Copyright©2004-2018, BCCN.NET, All Rights Reserved