c++ - How do I store multiple values into an array to be printed out later? -


OK, here I am going to insert the code of this program which is developing to help me with work is. I do not want to go into too much detail on how it is used but the lower line is that I am creating a program: the user takes two values, adds them, and then stores them in an array

Now I can do this with a very simple linear program, but I have a hard time getting that when the program starts, the user will have two values To say the shoe, the program stores it, again as again, it will ask the user for two more values, then I want to store it again, depending on the statistics of the user's needs data So in the end, I want to print it all in the compromised values ​​in the end, I want to export it to a txt file, but it will come later, I just want to Can anybody help me with it Niadi want to go down?

  #include & lt; Iostream & gt; # Include & lt; Set & gt; Double DCordinate (Double X) {Return X / 1000; } Zero store (int x, int y) {int anCoorValues ​​[] = {x, y}; } Int main () {std :: cout & lt; & Lt; "How many data points do you need to enter?" & Lt; & Lt; Std :: endl; Int nAmountOfDataPoints; Std :: cin & gt; & Gt; NAmountOfDataPoints; {Std :: cout & lt; for int nCount = 0; nCount & lt; nAmountOfDataPoints; nCount ++} & Lt; "Enter E / W coordinates" & lt; & Lt; Std :: endl; Double DEU; Std :: cin & gt; & Gt; Dew; Std :: cout & lt; & Lt; "Enter N / S Directions" & lt; & Lt; Std :: endl; Double DNS; Std :: cin & gt; & Gt; DNS; Stores (dCoordinates (dew), dCoordinates (DNS)); You must declare a container in the main form and then make it another form of the form. You should give a parameter if you need to do this, then at any time you can produce the container. In your case this  std :: vector & lt; Std :: pair & lt; Double, double & gt;  

For example (the way the function type near the store store int?)

  #include & lt; Vector & gt; #includde & lt; Utility & gt; Double DCordinate (Double X) {Return X / 1000; } Zero Store (std :: vector & lt; std :: pair & lt; double, double & gt; & amp; amp; amp; amp; amp; amp; ;.,;; double x; double y} {v.push_back ({x, y}); } Int main () {std :: cout & lt; & Lt; "How many data points do you need to enter?" & Lt; & Lt; Std :: endl; Int nAmountOfDataPoints; Std :: cin & gt; & Gt; NAmountOfDataPoints; Std :: vector & lt; Std :: pair & lt; Double, double & gt; & Gt; V; V.reserve (nAmountOfDataPoints); // ... // Here you have the constricted vector (const std :: pair & lt; double, double & gt; & amp; p: v) {std :: cout & lt; & Lt; "(" & Lt; & lt; p.first <<"," & lt; p.second <"& lt;") "& lt; & Lt; Std :: endl; }  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -