# C語言 題目 怎嚜解題

請C語言的大大幫幫忙
小妹剛學C語言 不太會解這一題 希望有人能提供解法
題目:
Do you know that there are squares within a square. This might seem confusing, but take a look at this.
Suppose you have a square grid of size 5 X 5 completely filled with integers.
You can make three squares from the table above… well there are more but...
show more
請C語言的大大幫幫忙

小妹剛學C語言 不太會解這一題 希望有人能提供解法

題目:

Do you know that there are squares within a square. This might seem confusing, but take a look at this.

Suppose you have a square grid of size 5 X 5 completely filled with integers.

You can make three squares from the table above… well there are more but we will consider only concentric squares. The squares are denoted using different fonts.

In this problem you have to find the sum of the numbers of each square.

For the above case the sums are

5 + 3 + 2 + 7 + 9 + 1 + 4 + 5 + 6 + 1 + 1 + 1 + 4 + 5 + 6 + 3 = 63

7 + 4 + 2 + 3 + 4 + 3 + 4 + 5 = 32

2 = 2

Input

There will be several lines in the input file. Each case starts with an integer n(n<=10) that determines the dimension of the square grid. Each of the next n lines will contain n integers each that will fill the square table in row major order. Input is terminated by a case where n == 0.

Output

Each line of output will start with “Case #:” where # is replaced by the case number. Then you have to output ceil(n/2) space separated numbers that will represent the sums from outer to inner. Follow the sample for exact details.

題目來源網址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2465

先在這邊感謝來回答的大大們

小妹剛學C語言 不太會解這一題 希望有人能提供解法

題目:

Do you know that there are squares within a square. This might seem confusing, but take a look at this.

Suppose you have a square grid of size 5 X 5 completely filled with integers.

You can make three squares from the table above… well there are more but we will consider only concentric squares. The squares are denoted using different fonts.

In this problem you have to find the sum of the numbers of each square.

For the above case the sums are

5 + 3 + 2 + 7 + 9 + 1 + 4 + 5 + 6 + 1 + 1 + 1 + 4 + 5 + 6 + 3 = 63

7 + 4 + 2 + 3 + 4 + 3 + 4 + 5 = 32

2 = 2

Input

There will be several lines in the input file. Each case starts with an integer n(n<=10) that determines the dimension of the square grid. Each of the next n lines will contain n integers each that will fill the square table in row major order. Input is terminated by a case where n == 0.

Output

Each line of output will start with “Case #:” where # is replaced by the case number. Then you have to output ceil(n/2) space separated numbers that will represent the sums from outer to inner. Follow the sample for exact details.

題目來源網址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2465

先在這邊感謝來回答的大大們

Update:
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2465

Update 2:
11470 - Square Sums 他的網址連結好像怪怪的

Follow

2 answers
2

Are you sure you want to delete this answer?