Interesting C Language Programs

Source: Internet
Author: User

 

I recently flipped through the "C program design" textbook by Mr. Tan haoqiang and made some exercises by the way. This book is a course material for undergraduate students, so when I look at it, there is a feeling of seeing old friends. Below I will write down some interesting questions and programs for your needs.

 

1. Find "Sn = a + aa + aaa +... + Aa... A "value, where a is a number, n is the number of items, and a and n are input by the keyboard.

 









 

 

2. Output all "Daffodils ". The so-called "Daffodils" refers to a three-digit number. The cubes of all its numbers are equal to the numbers themselves.

 

 

 

 

 

 

3. If a number is equal to the sum of its factors, this number is called "complete number ". For example, 6 is a factor of 1, 2, 3, and 6 is 1 + 2 + 3. Therefore, 6 is a "complete number ". Program to find all "completions" within 1000 ".

 

 

 

 

4. output the Yang Hui triangle.

 

 

 

5. Use recursion to convert an integer n into a string. For example, if you enter 483, the "483" character string should be output ". N digits are not fixed.

 

 

 

 

6. There are n integers, so that the numbers above are moved backward to m positions, and the last number of m is changed to the first number of m.

 

 

 

 

7. There are n people in a circle with sequential troubleshooting. When the first person reports the number (from 1 to 3), the person who reports the number 3 leaves the circle and asks the last person who left the number.

 

 

 

 

8. Compile a function to compare two strings and write a strcmp function.

 

 

 

 

9. Compile a function alloc () to create a continuous space (n characters) in the memory area ).

 

From the blog of Zhao Xiong

Related Article

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.