C applet to help find mistakes, a C applet bug

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

    The main thing is that you put this line using namespace std; Put it in main(), and then call cout to output it, so you should put it in front, or add it directly to the header file. h can be used, or it can be placed in front of the function in which iostream is called. Such as:

    You can put it in void hans1(void).

    cout<<"1111111111111111"void hans1(void);

    void hans2(void);

    int main()

    hans1();

    hans2();

    return 0;

    void hans1(void)

    cout<<"1111111111111111"void hans2(void);

    int main()

    hans1();

    hans2();

    return 0;

    void hans1(void)

    cout<<"1111111111111111"void hans2(void);

    int main()

    hans1();

    hans2();

    return 0;

    using namespace std;

    void hans1(void)

    cout<<"1111111111111111"cout<<"2222222222222222""That's fine. Is there anything else you don't understand? If there is anything you don't understand, ask me again.

  2. Anonymous users2024-02-07

    To start by adding a line.

    using namespace std;

    Do not write in the main function, write before main, otherwise the scope will not reach the global level.

  3. Anonymous users2024-02-06

    There is nothing wrong with the algorithm itself, it is a problem that the C++ integer range is out of bounds.

    float ele=float(k*k*k)/(n*n*n*n);

    The n*n*n*n in this is still an integer, when n=1000, the fourth power is followed by the 12th power of 10, which is beyond the range of the integer in c++, and becomes negative after overflow.

    The solution is to modify the expression so that the result of the operation is automatically converted to floating-point. e.g. float ele=float(k*k*k) ((float)n*n*n*n); or float ele=float(k*k*k) n n n n n; Both.

    By the way: n*n*n*n is invariant in the loop, so mentioning outside the loop will improve the efficiency of the program.

  4. Anonymous users2024-02-05

    It should be overflowing, you should just use the double type.

    #include

    int main()

    cout

  5. Anonymous users2024-02-04

    If you look at that page, there is a range of values for the variable type, and the system will not report an error if it exceeds the maximum value, but the value is incorrect.

    The int is signed, and exceeding the maximum value will change the first digit to one, which is displayed as a negative number.

    This can be seen in the original code, reverse code, complement code and other numerical value storage methods.

Related questions
7 answers2024-05-02

In the whole main function, only this one variable, whether it is the first for or the second for, is the same i, the second for will have i=-1, in the case of i= -1, and printf("%d ",a[i]);Statement. So fear not! When there is no second for the case: >>>More

10 answers2024-05-02

There is no contradiction, the types are matched. Added a note to your **, if you still don't understand, you can ask me again! >>>More

5 answers2024-05-02

Define an array of scores to record scores, record rankings and score bins. >>>More

6 answers2024-05-02

What program do you need? What is the concept of small?

11 answers2024-05-02

Guess it's a certain eggache teacher asking for a pointer or an array of pointers, right? >>>More