Programmer exam remedial note - the next day

zhaozj2021-02-16  45

Because the teacher touched the relationship between our teachers, I had to make up the base part of the previous one. He first lists a table of data types, as follows:

| Integer | Character | Basic Type <| Single Jield | | Real (Floating Point) <| | Enumeration Type | Double Accuracy | Data Type <| Array Type | Construction Type

The above table, the basic type is our usual use, including integer, characteristic, real (floating point), starting with the most common data type here. To talk about the data content of the C language, it is necessary to talk about what is stored in the computer. You should know that the computer can only handle the number of binary, because it is hardware relationship (bibly devices), these can only There are two states of representation, so it is particularly useful in the computer. From now on, we have to know all the data processed by the computer, then how do he calculate? Teacher first conversion to some of the counts into a number of binary counts, these pediatrics are of course no problem, very simple. The teacher, of course, we know that we will do, but in fact, we think that we can find a simpler conversion method when doing these topics. Example: 10111012 = (93) 10 It is very simple to calculate, my method is the traditional calculation method. They all have their own rights, the first one is 20, the second is 21, followed by some types of push, will take the number of 1 to the number of points to add together, equal to 93. Here is that in fact, the second-party secondary is particularly good, just like our memory, 1-2-4-8-16-32-64-128-256-512-1024 ... Do you know this law? If you know if it is calculated, don't do it! However, the teacher puts forward a better way here, at least than a one plus it. It is the number of times the number to be converted to 111111, how much is this number? In fact, there is a skill in it, look at 100,000,000 minus 1! So, is it soon you know how much is 10000000, it's ok, it's 128, and then 1 is 127. On the basis of the two numbers of the original binary bit of zero, the first one Zero in the second, so 2, the second zero in the sixth place, so 32, add it to 127 to lose 93, is it very simple and convenient? (Learn something fast tuition fee) Ah, haha ​​~!). Do you know what kinds of calculations in binary in your computer? I am here to tell you, in fact, there is only such a kind, it is the addition operation (you don't tell me that you will even make a binary addition, it is actually a pong two). Why do you say this way? In fact, the binary also has subtraction operations and multiplication, but there is a method of complementing complement in the computer, which can convert the subtraction operation into an additional operation. As for how to implement teachers, there is no more discussion (in some additions, multiplication is also use shifts Implementation to additional). Now transferring into the integer data of the C language, the integer data of the C language is 2 bytes, which is 16 bits, up to 65536, and his range is -32768 to 32767. The C language is divided into symbol type and unsigned type. If there is no symbol, the range of integers is 0 to 65535. Regarding character data, if it is strict, there is no character in the C language, because he is stored is its ASCII code.

Directly can be used and other data type operations, such as: main () {char s = 'a'; int i = 2; s = s i; printf ("% d", s); / * Here you can Outputs its ASCII code * / printf ("% c", s); / * Here the result is that the above statement changes the characters of the character S, then the 'c' * /} is more than the string, so String is only used in C language to represent the array, and other high-level languages ​​are different, with their string types, but also characters and strings combined in the same type. Now let's talk about the real data, the type type is usually used in some of the data. Just like this: s = 1/1 1 / 3-1 / 5 1/7 ... 1 / 2N-1 This program is I wrote: main () {Int n, i, s; int R = 1; Printf ("please input:"); scanf ("% d", & n); for (i = 1; i <= n; i ) {s = s r / (2 * i-1); R = -1 * r;} Printf ("% d", s);}

This is the test in the test: void fun (float * sn, int N) {float s = 0.0, w, f = -1.0; int i = 0; for (i = 0; i

I have done it to the two empty in the exam, but the procedure written by myself is a big problem. It is the answer to use integer data. From answering the answer, the answer should be a decimal, really a confused can be dead. what! Almost everyone is wrong, of course, there are alternative wrong methods, just use some of the operators of QB before, ^ This is the secondary operator in QB, this is really a joke. After that we want to compile a master to call this function.

I am main () {float s; int N; Printf ("PLEASE INPUT:"); Scanf ("% D", & N); FUN (& S, N); Printf ("% f", s) }

This is such a few simple statements, but it is almost everyone (except me). Do you know their answers? Let me show it out.

Main () {float * ss; int N; Printf ("please input:"); scanf ("% d", & n); fun (* ss, n); / * Here you have a problem * / printf ("% f ", * ss);

He can not know the problem of the function parameters in the C language, neither a variable that can be stored, and the parameters are also used, if you really have to have a pointer to point to a storage unit! . And it is not the address, but he tries to pass a pointer pointing to the unit into the function, which is absolutely wrong. Because the function of the call is the address, ok, the program gives him correctly. as follows:

Main () {float * ss, s; / * Here more unique variables * / int N; SS = & S; Printf ("please input:"); scanf ("% d", & n); fun * SS, N); / * There is a problem here * Printf ("% f", * ss);} Ok, so this program is completely correct, but to save space, use I write. Because don't do more, you will do a pointer variable. I have written special long today, and I also especially smell, I hope everyone will forgive me.

转载请注明原文地址:https://www.9cbs.com/read-27224.html

New Post(0)