How to do this C language question, thank you, be fast! Add a program to the green!!

Updated on technology 2024-04-20
10 answers
  1. Anonymous users2024-02-08

    Here's an example of using C++ to implement a number deletion operation for a given rule

    <> in the Upper Song Hall, we used a vector container to store the nums to be deleted and the deleted nums. Each loop, we calculate the index of the number to be deleted according to the rules and add it to the pruning sequence. The number is then removed from the original sequence using the erase() function.

    You can modify the input and output methods as needed, as well as perform other operations according to the actual requirements.

  2. Anonymous users2024-02-07

    #include

    include 《Lead Kai vector>

    int main()

    std::vectornumbers;Store a string of numbers.

    int n;

    std::cout "Please enter a string of numbers, separated by spaces, and end with -1" std::endl;

    Enter the number and store it in the vector.

    while (std::cin >>n &&n !=1) {

    Decryption process. while ( 1) {

    Delete 1 number of rental lots.

    Put the second number at the end of the locust type call.

    int temp = numbers[0];

    Output the decryption result.

  3. Anonymous users2024-02-06

    Here's how to decrypt QQ numbers using C++:

    #include

    std::string decryptqqnumber(const std::string& encryptedqq) {

    std::string decryptedqq;

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

    decryptedqq +=encryptedqq[i];

    return decryptedqq;

    int main()

    std::string encrypted";The encrypted QQ number.

    std::string decryptedqq = decryptqqnumber(encryptedqq);

    std::cout "The QQ number after decryption is:"then coarsely contains < decryptedqq The program defines a decryptqqnumber function, which accepts an encrypted qq number as input and returns the decrypted qq number. The program adds the number that needs to be kept to the decrypted QQ number by iterating through the encrypted QQ number, skipping one digit at a time.

    In the main function, the encrypted QQ number is passed to the decryptQQnumber function for decryption, and the decrypted QQ number is output.

    Note that this is just a simple example implementation. In practice, you may need to optimize and expand it according to your specific needs. For example, add input validation, handle exceptions, and so on.

  4. Anonymous users2024-02-05

    a[i] =10* (i+2-5*(i>2)) 6;

    When i = 0.

    a[0] =10* (0+2-5*(0>2)) 6;0>2) is a judgment statement, 0 greater than 2 is false, and the result is 0

    20 % 6 is rounded.

    When i = 1.

    a[1] =10* (1+2-5*(1>2)) 6;1>2) is a judgment statement, 1 is greater than 2 is false, and the result is 0

    30% 6 is taken as the remainder.

    When i = 2.

    a[2] =10* (2+2-5*(2>2)) 6;2>2) is a judgment statement, 2 is greater than 2 is false, and the result is 0

    40 % 6 is taken as the remainder.

    When i = 3.

    a[3] =10* (3+2-5*(3>2)) 6;3>2) is a judgment statement, 3 is greater than 2 is true, and the result is 1

    0 % 6 is taken as the remainder.

    When i = 4.

    a[4] =10* (4+2-5*(4>2)) 6;4>2) is the judgment statement, 4 is greater than 2 is true, and the result is 1

    10 % 6 is taken as the remainder.

    When i = 5.

    a[5] =10* (5+2-5*(5>2)) 6;5>2) is a judgment statement, 5 is greater than 2 is true, and the result is 1

    20 % 6 is rounded.

    The result is as follows:

  5. Anonymous users2024-02-04

    The result was 142.

    Step 1: int x[5][5]=,12,14,16,18,20},21, 22, 23,24,25},1,2,3,4,5},3,5,7,9,11}}; This sentence defines a two-dimensional array x and gives the initial value (a set of numbers in each curly bracket is a line for the array).

    Step 3: Run the sum,for(i=0; i<5;i++)

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

    s+=a[i][j];

    It is a two-layer loop, each time i loop is executed, a j cycle is executed completely, and each j loop is executed, the value of a[i][j] is taken and added to the variable s, and finally the value of s is returned.

    Here the initial value of the j loop is affected by i (j = i + 1), so the order of the cycles:

    The first i cycle: i takes 0, and then executes j loop, j takes the values of 1, 2, 3, 4, s=s+a[0][1]+a[0][2]+a[0][3]+a[0][4]=0+7+8+9+10=34 (the initial value of s is 0).

    The second i cycle: i takes 1, and then executes the j cycle, j takes the values of 2, 3, 4, s=s+a[1][2]+a[1][3]+a[1][4]=34+16+18+20=88.

    The third i cycle: i takes 2, and then executes the j cycle, j takes the values of 3 and 4 respectively, s=s+a[2][3]+a[2][4]=88+24+25=137.

    The fourth i cycle: i takes 3, and then executes j loop, j takes the value of 4 respectively, s=s+a[3][4]=137+5=142.

    The fifth i cycle: i takes 4, and the j cycle is not executed.

    Step 4: The end of the loop returns the value of s 142 and prints it in the main function.

    Note: The x array is passed as a parameter, passing the address, although this question does not change the value of the array, but if you change the value of an element of the A array in sum, you will find that the x array also changes.

    Also your printf statement is missing the slash printf("%d",sum(x));

  6. Anonymous users2024-02-03

    Row number i, column number j, meet i>=j below the left diagonal line of the data +1

  7. Anonymous users2024-02-02

    Beginners can set breakpoints, step through cycles, and see variable changes

    for loop, the initial value of i is 5, i+=4 is i=i+4 step 4, i=i+3 and step 3 in the circulation body, so each cycle i increases by 7, and the s value is calculated before i step s+i until i<17 This condition is not true to exit the loop.

    When it first started: i is 5, s is 2019;

    At the beginning of the second time: i is 12, s is 2024, meets i<17, continues;

    At the beginning of the third time: i is 19, s is 2036, i<17 is not satisfied, exit.

    So in the end i is 19 and s is 2036.

  8. Anonymous users2024-02-01

    Key knowledge points, the order of operations of the for loop:For loops we can express as:

    for(Expression1; Expression 2; Expression 3).

    Statement; When the program is running:

    Solve Expression 1.

    Solve Expression 2. If its value is true, execute the inline statement specified in the for statement, and then execute step 3; If the value of expression 2 is false, end the loop and go to step 5.

    Solve Expression 3.

    Go back to step 2 above and continue.

    When the loop ends, execute the statement below the for statement.

    Comparison question: First i = 5, i < 17 satisfied, execute the for loop inline statement:

    s = s+i --s = 2019+5 = 2024;

    i = i+3 --i = 5 + 3 = 8;

    Then run for statement expression 3:

    i+=4-->i = i+4 --i = 8+4 = 12;

    12 < 17 meet the requirements and continue to run:

    s = s+i --s = 2024 + 12 = 2036;

    i = i+3 --i = 12 + 3 = 15;

    Then run expression 3: in the for statement

    i+=4-->i = i+4 --i= 15 + 4 = 19;

    19 < 17 is false, the for cycle ends;

    So after the end of the for loop: s = 2036, i = 19;

    Printed as: 19, 2036

  9. Anonymous users2024-01-31

    s=2019;

    for(i=5;i<17;i+=4)

    s=s+i;

    i=i+3;

    In this case, you can only simulate the process, the first cycle.

    s=s+i;i.e. s=2019+5=2024;

    i=i+3;i.e. i=5+3=8;

    After that, the i+=4 of for will be executed; That is, i=8+4=12i<17 is established, and the next cycle continues.

    The second cycle.

    s=s+i, i.e., s=2024+12=2036;

    i=i+3;i.e. i=12+3=15;

    i+=4, i.e. i=15+4=19;

    Because i<17 does not hold and the loop exits, the final result is 19,2036

  10. Anonymous users2024-01-30

    According to **, s is the sum of all integer numbers in array a, and c is the number of digits divisible by 4.

    So choose b, 5, 96

Related questions
6 answers2024-04-20

The procedure is as follows,You can paste your**,Everyone**There is a mistake there.,ACM's questions pay attention to formatting.,It's wrong to get the format wrong.。 >>>More

8 answers2024-04-20

n!is the factorial of n, and its mathematical meaning is n!=1*2*3*4*..The NC language implementation is as follows: (the program is debugged in the Turboc environment) int factorial(int n). >>>More

22 answers2024-04-20

ab=18 AB is divided into three equal parts from AC=2BC, from D is the midpoint of the line segment AB, E is the midpoint of the line segment CB, and DE=6 gives 3DE=AB, so AB=18

11 answers2024-04-20

Let's say there are a total of x balls in the bag.

The starting red ball accounts for 1 4, then the starting red ball has 1 4*x. >>>More

8 answers2024-04-20

There are n-1 zeros, respectively in the interval [1,2],[2,3].n-1, n]. >>>More