Write a passable code

Source: Internet
Author: User

 

Nikos Theorem

 

/* Verify the nikucus theorem, that is, any integer cube can be written into a string of consecutive odd numbers and. & Times; * problem analysis and Algorithm Design
This question is a theorem. Let's first prove that it is true.
For any positive integer a, whether a is an odd or even number, the integer (A & times; a-A + 1) must be an odd number.
Construct an arithmetic difference series. The first item of the series is (A & times; a-A + 1), and the difference value of the arithmetic difference series is 2 (odd number series). Then, the sum of the first item A is:
A & times; (A & times; a-A + 1) + 2 & times; a (A-1)/2 = A & times; a & times; a-A & times; a + A & times; a-A = A & times;
Theorem is true. Pass.
Through the proof of the theorem, we can see that the first entry of the odd number series required by L is (A & times; a-A + 1) and the length is. Programming algorithms do not require special design. They can be directly verified based on the proof of theorem.

OJ prompts that the memory is out of bounds. Next time, let's take a look .. Do not interrupt point recording */

# Include <stdio. h> int main (void) {int ipan [20] = {0}; int icup, ibowl, I, j; icup = ibowl = I = J = 0; scanf ("% d", & icup); ipan [0] = ibowl = (icup * icup-icup + 1); While (ibowl! = Icup * icup) {ipan [I] = ipan [I ++] + 2; ibowl + = ipan [I];} J = I + 1; I = 0; printf ("% d * % d =", icup * icup); While (I <j) {printf ("% d", ipan [I ++]); if (I! = J) putchar ('+');} return 0 ;}


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.