The path to learning in Python--08 basic articles

Source: Internet
Author: User

In Python it is stated that a two-dimensional array can be sized with a for-I in range (x) so that it can be the same as the implementation-defined array in C, and that the array in the function is not required to be modified if it is to modify the value. It may be that the array declaration is not a reason to assign an initial value.

Learn about Python applications by topic:

Xiao Meng recently in the application of a rollover picture, you may also know that the picture is actually made up of a point. So, Xiao Meng want to first do a can flip the matrix program, to solve the core of his problem.

Input Format

Enter the first line to include integers separated by spacesM,n,t (0 < n,m < 200)M,N,T(0<N,M<200),TThe value of T is00 or11. whichMm  and   nn  represents the number of rows and columns of the matrix to be processed, tt  for  0< Span class= "katex-html" >< Span class= "Mord MATHRM" >0  when the left and right flips, for  1 < Span class= "Mord MATHRM" >1  when you flip up and down.

After the m-m line, each row consists of n-n integers separated by a space , followed by thedata for each row of the input matrix.

output Format

The output consists of mm row nn columns, separated by a space between each digit, with a space at the end of each line, representing the matrix after the request is flipped.

Sample Input
4 4 11 2 3 45 6 7 89 0 1 23 4 5 6
Sample Output
3 4 5 6 9 0 1 2 5 6 7 8 1 2 3 4
It's actually two functions, a line Exchange, a column exchange, with the emphasis on learning Python's two-bit beads declaration and enhancing the output of Python, Python's print default output wraps, but if we don't want to output line breaks, to output other characters, we can add end= after the output. Characters
Arr=[[0 forIinchRange205)] forIinchRange205)]p=[[0 forIinchRange205)] forIinchRange205)]def revers1 (m,n): forIinchRange (m): forJinchrange (N): P[m-i-1][j]=arr[i][j]def revers2 (m,n): forIinchRange (m): forJinchrange (N): P[i][n-j-1]=arr[i][j]x=input (). Split () M=int(x[0]) N=int(x[1]) T=int(x[2]) forIinchRange (M): x=input (). Split () forJinchRange (N): Arr[i][j]=int(X[j])ift==1: Revers1 (m,n)Else: Revers2 (m,n) forIinchRange (M): forJinchRange (N): Print (P[i][j],end=" ") print ()

The path to learning in Python--08 basic articles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.