Homework to do tomorrow

Source: Internet
Author: User

I want to try my best for this assignment because the C + + Foundation is not very good.

"1" The first question: Given an array, the implementation of the sum of the array elements, the specific requirements: to implement the one-dimensional array (a[100]) all elements of the addition operation.

I want to use the most primitive method of C + + to write, that is, stupid method. I've lost all that data in.

Then the test results are correct. It took me a long time because of such a stupid method.

"2" The second question: rewritten as a function (called arraysum), can be any length of the array of all elements of the sum

The second program just started I also manually input, but how to debug no, then I sent to my classmates to see, she felt that I this program is too low feasibility. I suggest I put the data in a document and read it in C + +. I just remember the file stream I learned in my freshman years.

At the beginning of the time, the. txt is in the wrong place, how is not the result, and then I complained to the roommates, in their help successfully modified. The result of the operation is correct.

"3" The third problem: rewrite the second question to be able to read data from the file, to implement any length array, the specified range of elements added.

Due to the experience of the second question, the third question is added a range.

When the third question started running, the results were different from what I thought, such as the data length is 5 and the array range is 1 to 2. However, the results are not shown as 1, 22 data is added, only 1 of the data is displayed. I tried a few times to find out that the maximum number of input ranges given in my program did not add "=". After the solution, the result is correct.

My GitHub link:https://github.com/MocQiQi/

"4" Summary: Through this job, I re-mastered the C + + file stream, the same learned how to put the TXT file in C + + read the data. There is just in the writing industry did not think of learning new knowledge, just want to use stupid method to write slowly. Later in the communication with the students found a new method, which let me know the importance of communication.

Homework to do tomorrow

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.