Have you learned that C language really can develop a lot of things?

Source: Internet
Author: User



Mario turns into a flower when he touches it.

What is Mario? A rectangle with 16x32 a small color block, some of which are filled with color, others are not. What is a flower? A 16x16 square. What is "change body"? Change the brown color of this box to red, which means that the red of the trouser is turned white. What is brown? For the moment, it is the 0x887000 number. What is "hit"? Mario's rectangle overlaps the square of the flower. What is "overlap"? Suppose Mario's This block occupies the screen (what is the screen?) A rectangle that can hold a 256x240 small color block) in the X-direction from 101 to 116, y-direction 21 to 52 of the area, so long as the region has a little or more points are also occupied by the flowers (such as flowers in the area of X 116 to 131, Y 21 to 36), I They think they overlap.

Given the two rectangular regions represented by eight values, write a C language program that determines whether two regions have overlapping. If you can write it out, then congratulations, if one day you want to do the NES version of "Super Mario", you at least know what it takes to make him become.

Yes, C language may "only" do math problems. However, the vast majority of the game's running process is to keep doing math problems, and so-called writing games, that is, the game's rules and the effect of the game into a mathematical problem. Many of the topics computers already know how to solve--the other programmer told it beforehand--for example, "Ask for a bunch of polygons scattered in the three-dimensional right-angled coordinate system in 8 (x−3) −10 (y+1) −11 (z−1) =0 the plane in a given range of projections" or "given some of the vertices connected to each other, Find the shortest path between any two points "math problem, it only takes one out of 10,000 seconds to give you a good solution." What is the use of this ability? The essential activity of FPS game on computer is to ask for the projection of the multi-plane of the three-dimensional coordinate system after transformation in the two-dimensional plane, constantly judge whether the two multi-faceted bodies overlap each other, and keep looking for the shortest path between the two vertices, and finally achieve the purpose of letting the monster to bite you in front of you. Not only the game, but other software is similar, every detail is a mathematical problem--such as the top of the page of the Blue navigation bar background, is a CSS description of a blue to dark blue gradient--what is the gradient? Given two numbers representing two colors, and the third number representing a distance, the number of colors and the order of a series of color, so that the distance between the two adjacent colors of the smallest change. Math problem. Don't say C, all programming languages can only do math problems, according to the given data, calculate the other data, calculate more data, and then store, send or present the calculated data.

But I can understand your confusion. Devote a lot of time to finish the tutorial, the result can only output a string of numbers in the black box. Is this a program of learning or a tribute to the 70? Is programming such an activity that does not give people a sense of accomplishment? Yes, it's not. Look at your statement, it should not be a child, because children do not because of the beginner program can do things very little and no sense of accomplishment, or that do not feel the sense of accomplishment of the children at all will not continue to learn. The sense of accomplishment of the initial learning program comes from "I can actually command the machine to do something", at least when I was a child, I used a program of Chinese learning to help me calculate the summer homework on the arithmetic problem is such feeling. Writing these programs and using it to solve a problem is much more time-consuming than putting it to work, but it makes people bored. I didn't know that when Mario met the flower, it was programmed by programming, so I wouldn't want to learn to program "andcan'tWhat to do. "

It is difficult for most people to rely on the simple and primitive pleasures of "I can command the machine" to drive themselves to learn programming. Have seen the past, heard rumors, desire and ambition become complex and huge, you want to graphics interface, music sound, artificial intelligence, cloud synchronization, but you have to learn a few lessons, or just learn to display a string of numbers in the black box. You suspect this is a C-language error, so you come up and ask this question.

There is a reason for your doubts.

If you can learn the programming, you will understand in the future, any program is an iceberg, the end user can see the interface and use the function, but the program floats on the surface of the one-tenth. Know this site is actually a running on a computer program, you can see the One-tenth is written with what? Html,css,javascript, or Objective-c. And the nine-tenths you don't see is written in what? Python. These Python programs you can't directly observe are running on some computers in some corner of the world, with fiber optic cables, twisted-pair cables, and wireless base stations that inject life into your front or handheld user interface.

(http/xkcd.com/353/ )

...... But what is Python written in? C language (of course, this is not rigorous, Python can theoretically be implemented in any other language, in fact, it has been implemented in many other languages, but this is not the focus). Any programming language is a tool to implement a feature, Python realizes most of the functionality of the site, and C implements the "write program in Python" feature. Why is C?

C is awkward and flawed, but surprisingly successful. While there is a history of coincidence, it is also true because it satisfies the need for such a system to implement a language: it is quite efficient to replace assembly language, and is sufficiently abstract and fluent to describe algorithms and interactions in a variety of environments.
C is quirky, flawed, and an enormous success. Although accidents of history surely helped, it evidently satisfied a need for a system implementation language efficient enough to displace assembly language, yet sufficiently abstract and fluent to describe algorithms and interactions in a WI De variety of environments.
father of--c language, Dennis M. Ritchie


C is the language of the first generation of programmers, when the hardware is expensive, the software must be efficient, and the computer users are professional programmers, the hardware has enough understanding. C is close to the hardware, it means it is easy to translate into a machine can understand the language, and its designers do not need to worry about ordinary people can be more difficult to learn-and, really, it is not difficult. But after all these years, the software became bigger and larger, and C was like a hammer and a hand-saw, and it was easy to build a skyscraper, but the C language could be used to create other tools that were better suited to building skyscrapers, or even prefabricated parts of skyscrapers, like using hammers and hand saws to build excavators and cranes, The concrete slab is the same as one of the doors and windows (of course, this analogy is not very appropriate. But there is no analogy to describe software engineering properly, because software engineering is like many things, but nothing like it.

So, back to your question, yes, learn C computer language can really develop a lot of things, but unless the internal force is deep, the occasion is appropriate, and the idle egg hurts, most people will not take C or only c to develop too big things. If you just want a language that allows you to "edit out a game or software," and you use Windows, it's recommended that you go to learn C #. It looks like C, but can quickly write at least with a graphical interface of the program, it is very convenient to use, the mouse point can let you to your own program look like a more intuitive impression. Also, in China, C # Textbooks are fairly easy to find. Of course, Python is also a good choice.


In addition, there is one thing you must understand: the modern so-called programming this activity, in fact, most of the time is in the "reasonable stacking of other people have realized the function to achieve new functions",c language, such as printf this thing, is someone else do it " The ability to output some data to the screen in a specified format. and others have done many other functions, such as "in the discovery of a user for a short period of time to press the mouse and release the time you write a function called". Learning how to use these existing functions in C or any other programming language is also a play to learn to program. When you figure this out, you'll find the answer to your question.

Tail Note: The picture is wrong. Mario body width should be 16 pixels, I drew 17.

Transferred from: Http://www.zhihu.com/people/Metaphox

Have you learned that C language really can develop a lot of things?

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.