close
Content
在這個問題中,根據所給的振幅(Amplitude)及頻率(Frequency),你的程式要產生這樣的波。
Input
輸入的第一列有一個整數n,代表有幾組測試資料。接下來每組測試資料有2列,各有1個正整數(A、F),A代表振幅(A<=9),F代表頻率。 第一列以及各組測試資料間皆有一空白行。請參考Sample input。
Output
每組測試資料請輸出F個波,每個波振幅的水平高度為A。波本身是以其"高度"的內容所組成。每個波之間以一空白行分隔開來。 測試資料間也以一空白行分開。 請參考sample output。
Sample Input #1
2

3
2
5
3
Sample Output #1
1
22
333
22
1

1
22
333
22
1

1
22
333
4444
55555
4444
333
22
1

1
22
333
4444
55555
4444
333
22
1

1
22
333
4444
55555
4444
333
22
1

 

python:(這樣的速度很慢,因為這是按照C++的語法去寫的,用py應該還有更好的寫法)

a0=int(input())
qq=input()
for _ in range(a0):
    a=int(input())
    f=int(input())
    for f0 in range(f):#總共幾個波
        for a0 in range(1,a+1):#列出的數字
            for i in range(a0):#列出一行有幾個
                print(a0,end='')
            print('')
        for i in range(a0-1,0,-1):
            for j  in range(i):
                print(i,end='')
            print('')
        print('')


 

arrow
arrow
    文章標籤
    python 高中生程式解題
    全站熱搜
    創作者介紹
    創作者 趴趴熊日常 的頭像
    趴趴熊日常

    資工趴趴熊的小天地

    趴趴熊日常 發表在 痞客邦 留言(0) 人氣()