In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the C language magic square matrix implementation methods, the article is very detailed, has a certain reference value, interested friends must read it!
Magic square:
Arrange 1 to n squares into n rows and n columns, so that the sum of the numbers on each row, column and diagonal in the square matrix is the same, that is, the magic square of order n.
According to the law of the magic square, I divide it into three cases.
1. Odd order magic matrix
Rule: the first number is placed in the middle of the first row, and the next number is placed in the next column of the previous number. If there is already a number in that position, it is the same column in the lower row of the previous number.
Programming in C language is as follows:
Example: nasty 5
# include#include#include void Magic1 () {# define ROW 5#define COL ROWassert (ROW% 2! = 0); / / determine whether n is odd [ROW] [COL] = {0}; / / define a two-dimensional array int currow = 0 currow curcol = COL / 2 currow [curcol] = 1 for (int I = 2; I)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.