Question
Woriking on how to get the input in one line suh as getline() but it is not working input as AL,Mobile,195111,(30.67762486480, -88.1184482714) AK,Anchorage,291826,(61.14986873100, -149.111113424) AZ,Phoenix,1445632,(33.57241386950,
Woriking on how to get the input in one line suh as getline() but it is not working
input as
AL,Mobile,195111,"(30.67762486480, -88.1184482714)"
AK,Anchorage,291826,"(61.14986873100, -149.111113424)"
AZ,Phoenix,1445632,"(33.57241386950, -112.088995222)"
AZ,Scottsdale,217385,"(33.68724936510, -111.865085877)"
AR,Fayetteville,73580,"(36.07121173120, -94.1659600436)"
AR,Fort Smith,86209,"(35.34916926360, -94.3696317306)"
and the outppput sach as :
#include
#include
using namespace std;
class City
{
public:
string city;
string state;
string pop;
string lat;
string lon;
City()
{
cout
}
};
int hash1(string city)
{
int len = city.length();
int sum = 0;
for (int i = 0; i { sum += city[i]; } return sum; } int hash2(string city) { int len = city.length(); int sum = 0; for (int i = 0; i { sum += city[i] * city[i]; } return sum; } void hash_display(City *arr[],int size) { // cout for (int j = 0; j { City *city = arr[j]; if(city != NULL) { cout state citypoplatlon } else { cout } } } void insert(City *arr[], bool isNULL[], City *c, int size, int count) { // cout int hash_value = hash1(c->city); // cout int i = hash_value; bool full = false; bool visited[size]; memset(visited, false, sizeof(visited)); // cout while (!isNULL[i%size]) { // cout if (visited[i%size]) { full = true; break; } if (arr[i%size]->city == c->city) { cout return; } cout city i = (i + i*hash2(c->city)) % size; if (i == hash_value) { cout full = true; break; } } if (full) { return; } count++; arr[i%size] = c; isNULL[i%size] = false; } int main() { int size; cout cin >> size; City *arr[size]; bool isNULL[size]; for (int i = 0; i { arr[i] = NULL; isNULL[i] = true; } string cityname, state, pop, lat, lon; string ch; int count = 0; do { cout cin >> state >> cityname >> pop>> lat >> lon; City *c = new City; c->city = cityname; c->state = state; c->pop = pop; c->lat = lat; c->lon = lon; insert(arr, isNULL, c, size, count); cout cin >> ch; } while (!(ch == "InsertionEnd") && count if(ch =="hash_display") { hash_display(arr, size); } //City c; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started