What s wrong with a simple C program

Updated on technology 2024-05-23
8 answers
  1. Anonymous users2024-02-11

    The reason is that you declare that the totleweight() function is a friend function of car, but you do not declare that it is a member function of boat, so you cannot directly access the private data members of the boat class.

  2. Anonymous users2024-02-10

    You only have a friend of the car class, and you don't have a friend of the boat class.

  3. Anonymous users2024-02-09

    The program is to copy the sequence 3 times and put it into str to avoid looping, that is, the three are concatenated together, so the total length len=3*length

    Line 16 means that if you cut it from the start position, then the second subscript from that position to the left is left, the second subscript on the right is right, char left is the character in the first position on the left, and char right is the first character on the right.

    Schematic diagram, taking the data of the question as an example:

    left right

    aaabbbadcc a a a b b b a d c c aaabbbadcc

    char_left char_right

    If cut in front of bead No. 4, i.e. start=4, then left=12, right=15, char left=str[13], char right=char[14];

    After that, the left pointer moves left to check the number of characters that are consistent with char left, and right to the right to check the number of characters that are consistent with char right, adding them up.

    The whole algorithm is the simulation method, just pay attention to the technique of using a copy sequence to convert the ring to linearity.

  4. Anonymous users2024-02-08

    `unit' has not been declared

    char lpszclassname="window";Punctuation marks in Chinese.

  5. Anonymous users2024-02-07

    There are 3 error points:

    Enter a real number in the line with quotation marks in Chinese, should be changed to English characters;

    The final output -a is not followed by "; ”

    Defining variable a as a double-precision floating-point number, and entering it as a single-precision floating-point number, there is an overflow fault, which will lead to a running error, as shown in the following figure

    It should read as follows.

    #include

    main()

    double a;

    printf("Please enter a real number:");

    scanf("%lf",&a);

    if(a>=0)

    printf("%f",a);

    elseprintf("%f",-a);

    Verified to be error-free.

  6. Anonymous users2024-02-06

    First, enter "should be changed to English" after a real number, and then printf("%f",-a) should be followed by a semicolon, and by the way, there is also a logical error, the first two places are syntax errors, scanf("%f",&a);, should be changed to scanf("%lf",&a);Because a is double-precision and %f is single-precision, this replication will lead to the loss of precision and the problem of non-compliance.

  7. Anonymous users2024-02-05

    Well said upstairs......That's ...... trueBut I look at lz's ** ......It's clear that you haven't developed the habit of programming ......Pay attention to the branch ...... each **Don't write a bunch of ...... togetherI don't want to look at ...... when I see itAnd be careful to write down notes ......You can still understand ...... with a small amount of programsWhen the amount is large, no one wants to watch ......After a long time, you will regret it when you forget to watch it again......I was like you ...... back thenNow the lesson has been learned......So now every time I write **, I have ...... annotationI'm writing a compilation, huh? It's so much uglier than you......Fortunately, the logic of my program is relatively clear ......(A bit arrogant.......)Haha)

  8. Anonymous users2024-02-04

    The double quotes in your first printf are Chinese......

Related questions
5 answers2024-05-23

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: >>>More

4 answers2024-05-23

Cite month[12][10]; Wrong. Without the element month[12][10], up to month[11][9], and the pointer p is useless. There's also the deletion of all your +10-level corresponding *. >>>More

9 answers2024-05-23

If you understand correctly, you want to use a common method to call, pass the parameters, the following is the easiest, if you want to make a common call method, you can try to add a form name parameter, modify the form appearance method. >>>More

8 answers2024-05-23

It's nonsense to say so much above. Landlord please see: pay attention to your program: printf("%d,%d",(a,b),(b,a); >>>More

12 answers2024-05-23

A full set of programs in five, when has C been so worthless.