11.17问题 D: 矩阵按列输出

本文介绍了一个简单的程序,该程序接收一个n*m的矩阵作为输入,并按列优先的顺序输出矩阵的元素。通过两次嵌套循环实现了矩阵的转置输出。

题目描述

对于n*m的矩阵,先输出第一列,然后输出第二列,依次类推,一直到输出最后一列为止

输入

输入两个整数n和m,n行m列(n和m均小于10)

接下去n行,每行m个整数

输出

先输出第一列,然后输出第二列,依次类推,一直到输出最后一列为止

两个数字间以空格隔开

样例输入

3 4
1 2 3 4
9 8 7 6
10 5 15 20

样例输出

1 9 10 2 8 5 3 7 15 4 6 20

 这题就没什么可说的,简单的变化,不过不太熟

#include <stdio.h>
int main(){
	int a[12][12];
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<n;j++){
			printf("%d ",a[j][i]);
		}
	}
}

 

[2025.06.10-11.17.46:469][ 0]CrashReportCoreLog: All uploads done [2025.06.10-11.17.46:469][ 0]CrashReportCoreLog: State change from SendingFiles to Finished [2025.06.10-11.17.46:735][ 0]LogPackageLocalizationCache: Processed 25 localized package path(s) for 2 prioritized culture(s) in 0.015662 seconds [2025.06.10-11.17.46:738][ 0]LogUObjectArray: 17291 objects as part of root set at end of initial load. [2025.06.10-11.17.46:738][ 0]LogUObjectAllocator: 4403640 out of 0 bytes used by permanent object pool. [2025.06.10-11.17.46:738][ 0]LogUObjectArray: CloseDisregardForGC: 0/0 objects in disregard for GC pool [2025.06.10-11.17.46:741][ 0]LogHAL: Linux SourceCodeAccessSettings: NullSourceCodeAccessor [2025.06.10-11.17.46:792][ 0]LogPython: Using Python 3.7.7 [2025.06.10-11.17.47:318][ 0]LogTcpMessaging: Initializing TcpMessaging bridge [2025.06.10-11.17.47:319][ 0]LogUdpMessaging: Initializing bridge on interface 0.0.0.0:0 to multicast group 230.0.0.1:6666. [2025.06.10-11.17.47:404][ 0]CrashReportCoreLog: Final state (Receiver) = Finished [2025.06.10-11.17.47:404][ 0]CrashReportCoreLog: Final state (Receiver) = Unknown UploadState value [2025.06.10-11.17.47:404][ 0]LogCore: Engine exit requested (reason: CrashReportClientApp RequestExit) [2025.06.10-11.17.47:404][ 0]LogExit: Preparing to exit. [2025.06.10-11.17.47:405][ 0]LogExit: Object subsystem successfully closed. [2025.06.10-11.17.47:406][ 0]LogModuleManager: Shutting down and abandoning module HTTP (12) [2025.06.10-11.17.47:406][ 0]LogHttp: Display: cleaning up 0 outstanding Http requests. [2025.06.10-11.17.47:439][ 0]LogModuleManager: Shutting down and abandoning module SSL (11) [2025.06.10-11.17.47:440][ 0]LogModuleManager: Shutting down and abandoning module CrashDebugHelper (8) [2025.06.10-11.17.47:440][ 0]LogModuleManager: Shutting down and abandoning module CoreUObject (6) [2025.06.10-11.17.47:440][ 0]LogModuleManager: Shutting down and abandoning module PakFile (4) [2025.06.10-11.17.47:440][ 0]LogModuleManager: Shutting down and abandoning module RSA (3) [2025.06.10-11.17.47:440][ 0]LogExit: Exiting. [2025.06.10-11.17.47:498][ 0]LogCarla: == CARLA Settings ============================================================== [2025.06.10-11.17.47:498][ 0]LogCarla: Last settings file loaded: [2025.06.10-11.17.47:498][ 0]LogCarla: [CARLA/Server] [2025.06.10-11.17.47:498][ 0]LogCarla: RPC Port = 2000 [2025.06.10-11.17.47:498][ 0]LogCarla: Streaming Port = 2001 [2025.06.10-11.17.47:498][ 0]LogCarla: Secondary Port = 2002 [2025.06.10-11.17.47:498][ 0]LogCarla: Synchronous Mode = Disabled [2025.06.10-11.17.47:498][ 0]LogCarla: Rendering = Enabled [2025.06.10-11.17.47:498][ 0]LogCarla: [CARLA/QualitySettings] [2025.06.10-11.17.47:498][ 0]LogCarla: Quality Level = Low [2025.06.10-11.17.47:498][ 0]LogCarla: ================================================================================ [2025.06.10-11.17.47:525][ 0]LogScript: Warning: Script Msg: A null object was passed as a world context object to UEngine::GetWorldFromContextObject(). [2025.06.10-11.17.47:525][ 0]LogScript: Warning: Script Msg: A null object was passed as a world context object to UEngine::GetWorldFromContextObject(). [2025.06.10-11.17.47:528][ 0]LogScript: Warning: Script Msg: A null object was passed as a world context object to UEngine::GetWorldFromContextObject(). [2025.06.10-11.17.47:536][ 0]LogScript: Warning: Script Msg: A null object was passed as a world context object to UEngine::GetWorldFromContextObject(). 1001[2025.06.10-11.17.47:644][ 0]LogLinker: Warning: 未能加载“{FileName}”:无法找到文件。 1001[2025.06.10-11.17.47:644][ 0]LogLinker: Warning: 未能加载“{FileName}”:无法找到文件。 [2025.06.10-11.17.47:644][ 0]LogUObjectGlobals: Warning: 寻找对象“Class /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_RHT.BP_TLOpenDrive_RHT_C”失败 CDO Constructor (TrafficLightManager): Failed to find /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_RHT.BP_TLOpenDrive_RHT_C [2025.06.10-11.17.47:644][ 0]Error: CDO Constructor (TrafficLightManager): Failed to find /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_RHT.BP_TLOpenDrive_RHT_C [2025.06.10-11.17.47:644][ 0]Error: CDO Constructor (TrafficLightManager): Failed to find /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_RHT.BP_TLOpenDrive_RHT_C 1001[2025.06.10-11.17.47:644][ 0]LogLinker: Warning: 未能加载“{FileName}”:无法找到文件。 1001[2025.06.10-11.17.47:644][ 0]LogLinker: Warning: 未能加载“{FileName}”:无法找到文件。 [2025.06.10-11.17.47:644][ 0]LogUObjectGlobals: Warning: 寻找对象“Class /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_LHT.BP_TLOpenDrive_LHT_C”失败 CDO Constructor (TrafficLightManager): Failed to find /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_LHT.BP_TLOpenDrive_LHT_C [2025.06.10-11.17.47:644][ 0]Error: CDO Constructor (TrafficLightManager): Failed to find /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_LHT.BP_TLOpenDrive_LHT_C [2025.06.10-11.17.47:644][ 0]Error: CDO Constructor (TrafficLightManager): Failed to find /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_LHT.BP_TLOpenDrive_LHT_C [2025.06.10-11.17.47:740][ 0]LogUObjectBase: Warning: -------------- Default Property warnings and errors: [2025.06.10-11.17.47:740][ 0]LogUObjectBase: Warning: Error: CDO Constructor (TrafficLightManager): Failed to find /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_RHT.BP_TLOpenDrive_RHT_C [2025.06.10-11.17.47:740][ 0]LogUObjectBase: Warning: Error: CDO Constructor (TrafficLightManager): Failed to find /Game/Carla/Blueprints/TrafficLight/BP_TLOpenDrive_LHT.BP_TLOpenDrive_LHT_C 这应该怎么办
06-13
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值