The second time the software is working

Source: Internet
Author: User

GitHub Link: Https://github.com/TYshadow/TYshadow

1. The first version of the program PROG1:
+ Given an array, implements the sum of the elements of the array, and specifically requires that all elements of a one-dimensional array (a[100]) be added.
+ Data Preparation: A) array length : 100;b) array data source : Experimental Data A column: 1~100,csv format fills the first 100 data.

problems encountered and solutions: the data in the CSV is separated by commas, while the C + + syntax defaults to reading only the characters that are separated by spaces, so you need to use a different method. Through Baidu and a series of forums found that the commonly used method is to create a string class Split function, but because it is not understood, instead of using the third parameter of the Getline function to solve the problem of the comma delimiter, the answer has been several times the wrong way, by setting breakpoints, the method of final resolution, But the sense function is too cumbersome. Temporarily turn over, think again revise.

2. The second version of the program PROG2:
+ Rewrite into a function (called arraysum), can realize the sum of all elements of any length array;
+ Data Preparation: A) array length : arbitrary; b) array data source : Experimental data column A.

The basic is to copy the first question, set the number of elements as parameters

3. Third version of the program Prog3:
+ Prog2 rewrite to be able to read data from a file, implement any length array, add elements within the specified range.
+ Data Preparation: A) array length : arbitrary; b) array data source : read from file.

The basic framework is still unchanged, the changes are only some of the details of the problem, such as about the upper and lower bounds on how to set, and the function of the parameter n is not used, should be removed, it is important to note that the test results when the parameters must be taken more than a few sets of parameters and different areas.

Summary: This experiment to learn the most important is not a program how to do, but the practicality of debugging, the importance of the previous learning process is too simple, even if there are errors can be seen from the program surface, but it will become more and more difficult to set breakpoints step-by-step debugging when the best method.

The second time the software is working

Related Article

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.