90-degree rotation of two-dimensional arrays

Source: Internet
Author: User

#!/usr/bin/env python
#-*-Coding:utf-8-*-
# @Time: 2018-01-15 20:40
# @Author: HHJ
# @Site:

#
# [0, 1, 2, 3, 4]
# [0, 1, 2, 3, 4]
# [0, 1, 2, 3, 4]
# [0, 1, 2, 3, 4]
# [0, 1, 2, 3, 4]
#----------------Two-dimensional array 90-degree rotation----
# [0, 0, 0, 0, 0]
# [1, 1, 1, 1, 1]
# [2, 2, 2, 2, 2]
# [3, 3, 3, 3, 3]
# [4, 4, 4, 4, 4]
Data=[[colFor ColInchRange10)]For rowInchRange5)]

For ColIn data:Print (COL)

# method One
For R_index,rowInchEnumerate (data):
For C_indexInchRange (R_index,Len (Row)):
Temp=data[c_index][r_index]
Data[c_index][r_index] =row[c_index]
Data[r_index][c_index]=temp

Print"--------------------%s"%r_index)
for RIn data:Print (R)
# method Two
n=Len (data)
For IInchRangeLen (data)):
A=[data[i][i]For rowInchrange (n)]
print (a)
# [0, 1, 2, 3, 4]
# [0, 1, 2, 3, 4]
# [0, 1, 2, 3, 4]
# [0, 1, 2, 3, 4]
# [0, 1, 2, 3, 4]
#----------------two-dimensional array 90 degree rotation----
# [0, 0, 0, 0, 0]
# [1, 1, 1, 1, 1]
# [2, 2, 2, 2, 2]
# [3, 3, 3, 3, 3]
# [4, 4, 4, 4, 4]
Gmt
Detect languageAfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDutch中文版EsperantoEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanLaoLatinLatvianLithuanianMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPersianPolishPortuguesePunjabiRomanianRussianSerbianSesothoSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshYiddishYorubaZulu AfrikaansAlbanianArabicArmenianAzerbaijaniBasqueBelarusianBengaliBosnianBulgarianCatalanCebuanoChichewaChinese (Simplified)Chinese (Traditional)CroatianCzechDanishDutch中文版EsperantoEstonianFilipinoFinnishFrenchGalicianGeorgianGermanGreekGujaratiHaitian CreoleHausaHebrewHindiHmongHungarianIcelandicIgboIndonesianIrishItalianJapaneseJavaneseKannadaKazakhKhmerKoreanLaoLatinLatvianLithuanianMacedonianMalagasyMalayMalayalamMalteseMaoriMarathiMongolianMyanmar (Burmese)NepaliNorwegianPersianPolishPortuguesePunjabiRomanianRussianSerbianSesothoSinhalaSlovakSlovenianSomaliSpanishSundaneseSwahiliSwedishTajikTamilTeluguThaiTurkishUkrainianUrduUzbekVietnameseWelshYiddishYorubaZulu
Text-to-Speech function is limited to characters
Options:History:Feedback:Donate Close

90-degree rotation of two-dimensional arrays

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.