|
@@ -6,10 +6,9 @@
|
6
|
6
|
![main1.png](images/main1.png)
|
7
|
7
|
![main2.png](images/main2.png)
|
8
|
8
|
|
9
|
|
-[Verano 2016 - Ive- Tatiana]
|
10
|
9
|
|
11
|
10
|
|
12
|
|
-Arrays help us to store and work with groups of data of the same type. The data is stored in consecutive memory spaces which can be accessed by using the name of the array and indexes or subscripts that indicate the position where the data is stored. Repetition structures provide us a simple way of accessing the data within an array.
|
|
11
|
+Arrays help us store and work with groups of data of the same type. The data is stored in consecutive memory spaces which can be accessed by using the name of the array and indexes or subscripts that indicate the position where the data is stored. Repetition structures provide us a simple way of accessing the data within an array.
|
13
|
12
|
|
14
|
13
|
|
15
|
14
|
|
|
@@ -155,7 +154,7 @@ In this laboratory experience, you are provided a `GPOI` class with the followin
|
155
|
154
|
---
|
156
|
155
|
## Reading Data from Text Files in C++
|
157
|
156
|
|
158
|
|
-This laboratory experience requires you to read data from a text file. You can skip the next section if you feel that your file reading skills are competent. Otherwise, read on...
|
|
157
|
+This laboratory experience requires you to read data from a text file. You can skip to the next section if you feel that your file reading skills are competent. Otherwise, read on...
|
159
|
158
|
|
160
|
159
|
|
161
|
160
|
C++ provides functions to read and write data to/from files. In this laboratory experience you will be using one of the most rudimentary file input/output schemes provided in C++ to read/write from **text** files. Text files consist exclusively of ASCII characters which represent data in any of the primitive types provided by C++. Typically, the values are separated by spaces. For instance let's assume that the file `nameAge.txt` contains some data about names and ages.
|
|
@@ -303,7 +302,7 @@ Here are some code snippets for common reading tasks. Observe that all of them:
|
303
|
302
|
1. Load the project `prMap` into `QtCreator`. There are two ways to do this:
|
304
|
303
|
|
305
|
304
|
* Using the virtual machine: Double click the file `prMap.pro` located in the folder `/home/eip/labs/arrays-prmap` of your virtual machine.
|
306
|
|
- * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/arrays-prmap` to download the folder `arrays-prmap` from `Bitbucket`. Double click the file `prMap.pro` located in the folder that you downloaded to your computer.
|
|
305
|
+ * Downloading the project’s folder from `Bitbucket`: Use a terminal and write the command `git clone http:/bitbucket.org/eip-uprrp/arrays-prmap` to download the folder `arrays-prmap` from `Bitbucket`. Double click the file `prMap.pro` located in the folder that you downloaded to your computer.
|
307
|
306
|
|
308
|
307
|
2. Compile and run the program. In its current state, the program simply displays a map of Puerto Rico. This map is provided so that you can visualize the results of your program. You may see some warnings which are due to the fact that some of the functions are incomplete. You will complete them throughout this laboratory experience.
|
309
|
308
|
|
|
@@ -321,7 +320,7 @@ Here are some code snippets for common reading tasks. Observe that all of them:
|
321
|
320
|
|
322
|
321
|
6. `double cycleDistance(GISPOI A[], int size, int P[])`: Given an array of cities `A`, the size of the array, and an array `P` with a permutation of the integers in `[0, size-1]`, computes and returns the distance to travel the cycle of cities `A[P[0]]` $$\rightarrow$$ `A[P[1]]` $$\rightarrow \cdots \rightarrow$$ `A[P[size-1]]`. Remember that the distance you will calculate is the *orthodromic* distance.
|
323
|
322
|
|
324
|
|
- For example, if the cities read from the file where Mayagüez, Ponce, Yauco and San Juan (in that order) and the permutation `P` is $$(3, 1, 0, 2$$, the function should compute the distance of a cycle from San Juan $$\rightarrow$$ Ponce $$\rightarrow$$ Mayagüez $$\rightarrow$$ Yauco $$\rightarrow$$ San Juan. **This is a function you will implement.**
|
|
323
|
+ For example, if the cities read from the file where Mayagüez, Ponce, Yauco and San Juan (in that order) and the permutation `P` is $$(3, 1, 0, 2$$, the function should compute the distance of a cycle from San Juan $$\rightarrow$$ Ponce $$\rightarrow$$ Mayagüez $$\rightarrow$$ Yauco $$\rightarrow$$ San Juan. **This is a function you will implement.**
|
325
|
324
|
|
326
|
325
|
|
327
|
326
|
There are two additional functions that you need to know:
|
|
@@ -341,7 +340,7 @@ Remember that you will only be changing code in the `main.cpp` file. Your first
|
341
|
340
|
1. In the `main()` function, add the necessary instructions to open the file that contains the georeferenced city information. The file that you will use first is `pr10.txt` that is in the `data` directory. You need to provide the complete `path` to the file as a parameter to the `open()` method of your `ifstream` object. As always, when using files you should verify if the entered name is a file that can be successfully opened for reading.
|
342
|
341
|
|
343
|
342
|
|
344
|
|
-2. Invoke the `int countLinesInFile(ifstream &inFile)` function to obtain the number of lines in the file. You may print out the number obtained so that you can validate is your program is working correctly.
|
|
343
|
+2. Invoke the `int countLinesInFile(ifstream &inFile)` function to obtain the number of lines in the file. You may print out the number obtained so that you can validate if your program is working correctly.
|
345
|
344
|
|
346
|
345
|
|
347
|
346
|
3. **Dynamically** create an array as big as the number of lines in the file.
|