Regarding the C language, ask the master of patience to explain each line. Thank you!

Updated on delicacies 2024-03-15
7 answers
  1. Anonymous users2024-02-06

    #include

    main()

    int a[4];Define an array of integers.

    int i,j;

    for(i=0;i<3;i++)

    scanf("%d",&a[i]);

    The above for loop assigns values to array elements a[0], a[1], and a[2] through the keyboard. When the loop exits, the value of i is 3

    a[i]='\0';Assign a[3] a value of 0, paying attention to the characters'\0'The ASCII code value is 0

    for(i=0;i<2;i++) The values of the outer loop i are 0 and 1 in order

    for(j=i+1;j<3;j++) inner loop, when i=0, j=1, 2, when i=1, j=2

    if(a[i]a[i]+=a[j];Equivalent to a[i]=a[i]+a[j];

    a[j]=a[i]-a[j];

    a[i]=a[i]-a[j];

    This is the end of the two-layer loop.

    for(i=0;i<3;i++) This loop is used to output the first three elements of the array: a[0], a[1], and a[2].

    printf("%-3d",a[i]);The output format is left-aligned, the width is 3, if the width exceeds 3, it will be automatically broken.

    This is the end of the cycle.

    printf("");Finally, a line break is output.

  2. Anonymous users2024-02-05

    press any key to continue

    I don't understand what the ** is actually for. See the comments for specific operations.

    #include

    int main()

    int a[4];

    int i,j;

    for(i = 0;i < 3;i++)scanf("%d",&a[i]);Read 3 integers from the keyboard.

    a[i] = '\0';Not at all.

    for(i = 0;i < 2;i++)

    for(j = i + 1;j < 3;j++)

    if(a[i] a[i] += a[j];Equivalent to a[i] = a[i] + a[j].

    a[j] = a[i] -a[j];That is, a[j] = a[i].

    a[i] = a[i] -a[j];a[i] remains unchanged.

    Overall, if a[i] for(i = 0; i < 3;i++)printf("%-3d",a[i]);

    printf("");

    return 0;

  3. Anonymous users2024-02-04

    I would like to recommend you a place to learn programming, where the godfather of programming is very popular, and learning programming is very popular, which will definitely make you useful in learning.

    Search for the godfather of programming, you can find it directly.

  4. Anonymous users2024-02-03

    <> "I. Initialization of Assignments.

    Many people know that this is how to statically initialize arrays: int fibs[1=, the C99 standard actually supports a much more intuitive and simple way to initialize a variety of different collection data (e.g., structs, unions, and arrays).

    2. Arrays. We can specify the elements of the array to initialize. This is very useful, especially when we need to keep some kind of mapping updated synchronously based on a set of define.

    Now, let's say we want to provide a string of error descriptions for each error code. To ensure that the array is up-to-date, we can use the syntax specified by this array, regardless of any changes or additions made to the header file.

    This allows you to statically allocate enough space and ensure that the largest index is valid, while initializing special indexes to the specified value and the remaining indexes to 0.

    3. Structure and Consortium.

    It is useful to initialize the data with the field names of structs and unions. Let's say we define :struct point and then we initialize struct point:

    truct point p {.x 3,.y 4,.

    z 5];When we don't want to initialize all fields to 0, this makes it easy to generate structs at compile time without having to call an initialization function. For the consortium, we can use the same approach, except that we only need to initialize one field.

    Fourth, the macro list.

    A common approach in C is to say that there is a list of named entities, and you need to establish functions for each of them, initialize each of them, and extend their names in different modules. This is often used in the source code of Mozi Training, and I learned this technique at that time.

    For example, in that project I worked on last summer, we had a list of macros tagged for each command. It defines a flag list macro that has a parameter called the argument itself a macro that can call every parameter in the list.

    5. Compile-time assertions.

    This is actually a very "creative" feature implemented using C macros. Sometimes, especially when programming kernels, it is useful to be able to conditionally check assertions at compile time, rather than balancing at runtime. Unfortunately, the C99 standard does not support any compile-time assertions.

    However, we can use preprocessing to generate **, which will only pass compilation if certain conditions are true (preferably the kind of command that does not actually do the function). There are a variety of different ways to do this, usually by building an array or struct of negative size.

  5. Anonymous users2024-02-02

    The purpose of this problem is to take the number characters of the power of "2" in a given string and combine them into an integer for output. Note the following:

    1. The function of the fun function is to judge the parameter x, t grows in the form of 2 squares, 2 to the 3rd power, and 2 to the 4th power in the loop, if x is equal to t, set the flag to 1, because in the C language, the non-0 value means "true", then through the flag value returned by the fun function, you will know whether the parameter x is the nth power of 2.

    2. In the main function, the passing argument is "p[i]-'0'p[i] represents the character on the ith bit in str1, and the character'0'Subtract to get the integer corresponding to the p[i] character.

    3、s=s*10+(p[i]-'0'), that is, the characters that meet the conditions are converted into corresponding integers, and a new number is formed from high to low. That is, s=0*10+8....s=8*10+4...

    s=84*10+2...s=842

  6. Anonymous users2024-02-01

    Didn't you write out your answer......?

  7. Anonymous users2024-01-31

    Question 46: Choose C.

    for statement: initialization, x=0, y=10;Next, y>0&&x<4 is judged to be true, so the cycle is repeated; If x++,y--, x=1 and y=9, y>0&&x<4 is true. Continue until the 4th time, when x=3 and y=7, y>0 is true, but x<4 is false, &&& is logic and relation, so y>0&&x<4 is false.

    Question 47: Choose C.

    When while (i++<4) is executed to 3, because it is i++, it participates in the judgment first, i=3, i<4, so it continues to execute, i=4, then i<4 is judged to be false, and the loop will not be executed, but after the judgment, ++ is to be performed, so the result of i is 5.

    Question 48: Choose D.

    At the end of the first do, x=4, y=2, continue the execution.

    At the end of the second do, x=2, y=1, x>y, continue the execution.

    The third cycle, x=2, y=0, x>y, continues the cycle, the fourth. Something went wrong, the denominator was 0, overflowing.

    Question 49: Choose C.

    I think it's uncertain. The data definition is not wrong, there is initialization, the line can be omitted, in this case, the behavior is 4, which is equivalent to char a[3]20]. a[30] points to an address? Please also ask for advice.

    Question 50: Choose A

    It's the same as pointers, there are many examples of using pointers as parameters and ordinary variables as parameters in the textbook, the array passes the address, and the operation on it directly affects the value of each element in the array.

    To be a good student, you have to rely on yourself... Hehe..

    Good luck.

Related questions
6 answers2024-03-15

C language is the language of writing system software, application software, such as Windows and DOS, are written in C language. Writing a program in C requires the compiler to convert the C format language into machine instructions, so that it can control the operation of the computer. Tuborc is the C environment under the DOC, VC, Brolandc is the C environment under the Windows environment.

7 answers2024-03-15

C language does not round, if you want to round it, such as a to keep two decimal places: >>>More

3 answers2024-03-15

It's still difficult to get to 6,5...

9 answers2024-03-15

This month is an auspicious month for the two of you to get married - excellent, there is no opposition to you! >>>More