# -*- coding: utf-8 -*- ''' 実行方法: python main.py < input.txt input.txtの中身: 1 2 3 4 5 6 A B C 7 8 9 ''' import sys arr = [] while 1: s = sys.stdin.readline() if len(s) == 0: break arr.append(s.split()) arr = zip(*arr) print('\n'.join(' '.join(e) for e in arr))
#初心者用
# coding:utf-8
n = int(raw_input( "行列の行の数を入力してください: " )) m = int(raw_input( "行列の列の数を入力してください: ")) a = [[] for x in range( n )] b = [[] for x in range( m )] for i in range( 1,n + 1 ): for h in range( 1, m + 1 ): a[ i - 1 ].append( raw_input( str( i ) + "行目の" + str( h ) + "列番目を入力してください: " ) ) for h in range( 1,m + 1 ): for i in range( 1, n + 1 ): b[ h - 1 ].append( 0 ) for d in range( n ): print a[ d ] for w in range( n ): for k in range( m ): b[ k ][ w ] = a[ w ][ k ] print "入力された値の転置行列は" for t in range( m ): print b[ t ]