A simple c procedure why it didn t turn out right

Updated on technology 2024-02-08
16 answers
  1. Anonymous users2024-02-05

    int main()

    int i,j,a[100];

    for(i=0;i<=99;i++) array from a[0] to a[99]a[i]=i;

    for(j=2;jif(a[i]%j==0) is not prime if it is divisible by a number other than 1 and itself.

    break;Going back to the previous for loop, i self-incrementing 1else if(j == i - 1) is prime.

    coutvs2005 compiled, the a[100] in it can be dispensed with, just replace it with i.

    int main()

    int i,j;

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

    for(j=2;jif(i%j==0)

    break;

    else if(j == i - 1)

    cout

  2. Anonymous users2024-02-04

    I just glanced at it and probably not accuratefor(i=0; i<=100;i++) is bound to be wrong.

    I don't want to write about it, but I can make some comments.

  3. Anonymous users2024-02-03

    Your second for statement should enclose if and else underneath

    k=int(sqrt(a[i]))

    for(j=2;j<=k;j++)

    if(a[i]%j==0)

    i++;else cout<

  4. Anonymous users2024-02-02

    Still won't work. The outputs are all 1s

  5. Anonymous users2024-02-01

    According to the data given by A and B, combined with the reaction equation, it can be known that the amount of input of A and B is the same. But because the container in B is movable and has a weight on top, the external pressure of container B is greater than that of A. Due to the pressure, in order to balance part of the pressure, the reaction proceeds in the direction of volume reduction, i.e., the equilibrium moves positively.

    Therefore, the amount of the reactant in A is greater than the amount of the reactant in B, so C is correct.

  6. Anonymous users2024-01-31

    Question 1:

    strcmp didn't understand correctly, strcmp has two situations when comparing the end of the program:

    1. Compare encounters"\0";

    2. Compare and encounter different characters.

    Your program only compares the last character.

    Question 2: if(*str1++>str2++).

    else if(*str1+++ As you can see from this structure, your pointer loop is added twice at once (if adds once else if adds again), which is the cause of your string alignment problems.

    Note: In the last comparison, if is not true, the pointer is added by one, else if the next character is not true, the pointer is added by one, and the else statement is executed, and the short string has pointed to zero and is not in the loop. Return 0.

  7. Anonymous users2024-01-30

    For single-precision numbers, when using the %f forger output, only the first 7 digits are significant digits, 6 decimal places, and if it is exceeded, it will be wrong, and if 0 is less than 7 digits, the usage of 10f is wrong, and the exact number of decimal places is. 10 , the exact decimal place is. 3. The decimal point cannot be lost.

  8. Anonymous users2024-01-29

    1. Where does the decimal 023 come from? Shouldn't the default 6 decimal places be 000?

    Floating-point numbers in computers are generally inexact numbers, which are approximate numbers, so when the output is over, when there are many decimal places, the display is not very different from our ideal number, and it will be better for you to replace it with double.

    2. Obviously the domain width has been specified as 10, why does the result have an 11-bit domain width, is it necessary to meet the decimal default output of 6 bits?

    Yes. 3. The output of the second printf() function is even more outrageous, only three digits are wide, why is the value fully output?

    When the width of the actual number exceeds the set field width, the output is based on the length of the actual number.

  9. Anonymous users2024-01-28

    Where does the decimal 023 come from?

    This is due to errors caused by binary decimal conversions. Therefore, a condition like x==y is not suitable for floating-point numbers.

    In other cases, the system will automatically complete the specified domain width to avoid output errors when the specified domain width is less than the actual numerical output accuracy.

  10. Anonymous users2024-01-27

    This error occurs because your character transfer group is not set in the last position'\0'Terminator, which causes printf to print strings out of bounds and garbled characters.

    There are two solutions:

    Scheme 1: Initialize all string arrays as follows:'\0', for example:

    char c[100] = , str[100] = ;

    Solution 2: Append the string to the last position'\0'Terminator, preceded by the printf function:

    str[j] = '\0';

  11. Anonymous users2024-01-26

    There are two questions. If statements are followed by a semicolon, and a terminator needs to be added to the end of the str string'\0', otherwise the output will be garbled.

  12. Anonymous users2024-01-25

    m = (3>2) &k=0); //k=5

    **The test points in the line are logical or (&&& are analyzed in detail as follows:

    Is 3 greater than 2? If it is greater than, the result is true!, k is directly assigned to 0 (i.e., false, define false 0), resulting in:

    m = true &&false;

    In logic or operations, both sides involved in the logic or operation must be true!Otherwise, the result is false (i.e. 0, define false 0)!

    Then m = 0; m is naturally assigned to 0, so imagine the result.

  13. Anonymous users2024-01-24

    The value of k=5 is assigned, and then the true value or false value is taken according to whether the value of k is 0, which is equivalent to:

    k=5; m=(3>2) &k;

  14. Anonymous users2024-01-23

    Yes, C thinks that 0 is false, and non-0 is true, you know. Then the assignment statement returns the value of the assigned object, that is, the value of k=0 is 0, and the value of k=5 is 5, so the result of the first one is m=0, and the result of the second one is m=1

    Actually, you can output a value of k=5, for example.

    printf("%d",k=5);

    The result is a value of 5,k.

  15. Anonymous users2024-01-22

    The above two are right, k=0, or k=5 are assignments, not comparisons, comparisons will have logical results, assignment is compared with the value of k, such as the question: the result is (3>2) &k, you see: m = (k=4); You get it.

  16. Anonymous users2024-01-21

    k=5, are you comparing or assigning value?

Related questions
5 answers2024-02-08

The belt gradually widened and did not regret it, and it made people haggard for Yi. >>>More

8 answers2024-02-08

Feng Ni Feng said very well and applauded.

7 answers2024-02-08

The lyrics of the interlude "You can only love one in your life". >>>More

23 answers2024-02-08

Well, I think whatever the problem is.

It's better for everyone to sit down and talk. >>>More

3 answers2024-02-08

1. Poisoning 2. Too much software.

3. Software Conflicts. >>>More