“This is the 13th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”

Question 1

๐ŸŽ— The number of loops in the while loop in the following program is

void main(a)
{
    int i = 0;
    while (i < 10) {
	if (i < 1) continue;
	if (i == 5) break; i++; }}Copy the code

๐Ÿ“ analysis:

Note the distinction between using continue and break in loops

Continue: Terminates the loop

Break: Breaks out of the loop

So this is an infinite loop

Second question

๐ŸŽ— the following program, output the correct result is ()

int main(a)
{
    int a = 5;
    if(a = 0)
    {
	printf("%d", a - 10);
    }
    else
    {
	printf("%d", a++);
    }
    return 0;
}
Copy the code

A. -5

B. 6

C. 1

D. 0

๐Ÿ“ analysis:

A = 0 is an assignment, it’s not a judgment, it’s false after a = 0, so else, and since a++ is postpended, it’s D

โ— On the other hand, this approach may still be a mistake. It is somewhat challenging for White to find such potential errors in five hundred lines of code โ•

All errors in programming can be grouped into three categories:

1๏ธ compiler error

This type is a syntax error and a relatively simple solution: just look at the error message (double click to locate the offending code).

2๏ธ link type error

LNK (link type error) this kind of error as long as you understand why it occurs, is also easy to find, right

The main reasons are:

โ–ถ This function is not defined at all

โ–ถ The calling function name is different from the defined function name

Solution: Error messages cannot be traced to the code in question, but can be relied upon

3 error of ๏ธ operation

This type of error has no error message and is relatively difficult to find. Generally, the output results do not match the expected or correct answer

Solution: Use debugging to locate the problem step by step


โ— The error in this problem is a runtime error โ•

In the case of less than 1 =, white can put the 3 on the left and then it becomes a compilation error, of course, you can follow the rules, the amount of code will definitely step on a wave of pit; If you get used to it, you won’t make mistakes, or you can locate problems quickly

The third question

๐ŸŽ— include <x.h> and include “y.h”, the following statement is correct ()

A. “” : Searches for header files in the source file directory

B. < > searches for header files in the source file directory

C. There is no difference between the two

๐Ÿ“ analysis:

The essential difference between โ— < > and “” include headers is: the difference in search strategy โ•

1๏ธ “” First look in the directory where the source file is located. If the header file is not found, the compiler looks for the header file in the standard location just as it looks for the library function header file. If it is not found, it will prompt a compilation error (so” “can also include the library file, but it is not necessary)

2๏ธ retail < > Directly go to the library directory to find

So that’s choice A

Number 4

๐ŸŽ— defines the variable double **a[3][4], which occupies ____ bytes of memory

A. 12

B. 24

C. 48

D. 96

๐Ÿ“ analysis:

Because [] has precedence over *, a is an array of Pointers with 12 elements of type double**. There are two ways to find the size of an address, so this is ambiguous:

1๏ธ on 32 (x86) bit platform, address occupies 4 bytes

4 times 3 times 4 is 48

2๏ธ on 64 (x64) bit platform, 8 bytes of address

8 times 3 times 4 is 96

So choice C or CHOICE D

Question 5 – Verifying the Goldbach conjecture

๐ŸŽ— programming questions < difficulty coefficient โญ >

๐Ÿ“ : The famous goldebach conjecture in mathematics roughly states that any even number greater than 2 can always be represented as the sum of two prime numbers. For example, 24 = 5 + 19, where 5 and 19 are prime numbers. The task of this experiment is to design a program to verify that even numbers up to 2 billion can be decomposed into the sum of two prime numbers.

๐Ÿณ Enter description.

The input gives an even number N in the range (2, 2 000 000 000 000) in one line.

๐Ÿณ Output description:

Output the prime decomposition of N in the format “N = p + q”, where p โ‰ค q is a prime number. And because such factorization is not unique (for example, 24 can also be decomposed into 7 + 17), it is required to output the solution with the lowest P of all the solutions.

๐Ÿ’จ example:

Input, 24

Output, 24 is 5 plus 19

๐Ÿงท Platform: Visual Studio 2017 && Windows

๐Ÿ”‘ Core Idea:

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<math.h> 
int prime(int x)
{
    int i = 0;
    for (i = 2; i <= sqrt(x); i++)
    {
	if (x % i == 0)
	return 0;
    }
    return 1;
}
int main(a)
{
    int n = 0;
    int i = 0;
    scanf("%d", &n);
    for (i = 2;; i++)
    {
	if (i % 2! =0 && prime(i) && prime(n - i))
	{
            printf("%d = %d + %d", n, i, n - i);
            break; }}return 0;
}
Copy the code