Having a list of N ordered pairs of the form (A,B)
Example input:
(200,500)
(300,100)
(300,100)
(450,150)
(520,480)
I want to get only the numbers from the input, so that I can use them within my Point structure, and use them to represent the location on a coordinate plane.
Here is my code:
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <fstream>
using namespace std;
struct Punto
{
double x,y;
double distancia;
double zona;
};
int main()
{
int n=4;
Punto arr[n];
int x, y;
for(int i=0; i<n; i++){
cin.ignore(); //(
std::cin >> x;
arr[i].x = x;
std::cout << "Punto " << i << " x " << x << '\n';
cin.ignore(); //,
std::cin >> y;
arr[i].y = y;
std::cout << "Punto " << i << " y " << y << '\n';
cin.ignore(); //)
}
return 0;
}
The problem is that this only works with the first entry but not with the following ones.
Aucun commentaire:
Enregistrer un commentaire