3rd semester files
This commit is contained in:
44
3rd-Semester-Fall-2022/PDS/Homework06/Makefile
Executable file
44
3rd-Semester-Fall-2022/PDS/Homework06/Makefile
Executable file
@ -0,0 +1,44 @@
|
||||
TARGET_EXEC ?= a.out
|
||||
|
||||
BUILD_DIR ?= ./build
|
||||
SRC_DIRS ?= ./src
|
||||
|
||||
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
|
||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||
|
||||
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
|
||||
|
||||
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
|
||||
$(CXX) $(OBJS) -o $@ $(LDFLAGS)
|
||||
|
||||
# assembly
|
||||
$(BUILD_DIR)/%.s.o: %.s
|
||||
$(MKDIR_P) $(dir $@)
|
||||
$(AS) $(ASFLAGS) -c $< -o $@
|
||||
|
||||
# c source
|
||||
$(BUILD_DIR)/%.c.o: %.c
|
||||
$(MKDIR_P) $(dir $@)
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# c++ source
|
||||
$(BUILD_DIR)/%.cpp.o: %.cpp
|
||||
$(MKDIR_P) $(dir $@)
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
clean:
|
||||
$(RM) -r $(BUILD_DIR)
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
MKDIR_P ?= mkdir -p
|
||||
|
||||
run:
|
||||
./build/$(TARGET_EXEC)
|
250
3rd-Semester-Fall-2022/PDS/Homework06/StatesInfo.txt
Executable file
250
3rd-Semester-Fall-2022/PDS/Homework06/StatesInfo.txt
Executable file
@ -0,0 +1,250 @@
|
||||
Alaska
|
||||
AK
|
||||
Juneau
|
||||
731,545
|
||||
665,384
|
||||
Alabama
|
||||
AL
|
||||
Montgomery
|
||||
4,903,185
|
||||
52,420
|
||||
Arkansas
|
||||
AR
|
||||
Little Rock
|
||||
3,017,804
|
||||
53,179
|
||||
Arizona
|
||||
AZ
|
||||
Phoenix
|
||||
7,278,717
|
||||
113,990
|
||||
California
|
||||
CA
|
||||
Sacramento
|
||||
39,512,223
|
||||
163,695
|
||||
Colorado
|
||||
CO
|
||||
Denver
|
||||
5,758,736
|
||||
104,094
|
||||
Connecticut
|
||||
CT
|
||||
Hartford
|
||||
3,565,278
|
||||
5,543
|
||||
Delaware
|
||||
DE
|
||||
Dover
|
||||
973,764
|
||||
2,489
|
||||
Florida
|
||||
FL
|
||||
Tallahassee
|
||||
21,477,737
|
||||
65,758
|
||||
Georgia
|
||||
GA
|
||||
Atlanta
|
||||
10,617,423
|
||||
59,425
|
||||
Hawaii
|
||||
HI
|
||||
Honolulu
|
||||
1,415,872
|
||||
10,932
|
||||
Iowa
|
||||
IA
|
||||
Des Moines
|
||||
3,155,070
|
||||
56,273
|
||||
Idaho
|
||||
ID
|
||||
Boise
|
||||
1,787,065
|
||||
83,569
|
||||
Illinois
|
||||
IL
|
||||
Springfield
|
||||
12,671,821
|
||||
57,914
|
||||
Indiana
|
||||
IN
|
||||
Indianapolis
|
||||
6,732,219
|
||||
36,420
|
||||
Kansas
|
||||
KS
|
||||
Topeka
|
||||
2,913,314
|
||||
82,278
|
||||
Kentucky
|
||||
KY
|
||||
Frankfort
|
||||
4,467,673
|
||||
40,408
|
||||
Louisiana
|
||||
LA
|
||||
Baton Rouge
|
||||
4,648,794
|
||||
52,378
|
||||
Massachusetts
|
||||
MA
|
||||
Boston
|
||||
6,892,503
|
||||
10,554
|
||||
Maryland
|
||||
MD
|
||||
Annapolis
|
||||
6,045,680
|
||||
12,406
|
||||
Maine
|
||||
ME
|
||||
Augusta
|
||||
1,344,212
|
||||
35,380
|
||||
Michigan
|
||||
MI
|
||||
Lansing
|
||||
9,986,857
|
||||
96,714
|
||||
Minnesota
|
||||
MN
|
||||
St. Paul
|
||||
5,639,632
|
||||
86,936
|
||||
Missouri
|
||||
MO
|
||||
Jefferson City
|
||||
6,137,428
|
||||
69,707
|
||||
Mississippi
|
||||
MS
|
||||
Jackson
|
||||
2,976,149
|
||||
48,432
|
||||
Montana
|
||||
MT
|
||||
Helena
|
||||
1,068,778
|
||||
147,040
|
||||
North Carolina
|
||||
NC
|
||||
Raleigh
|
||||
10,488,084
|
||||
53,819
|
||||
North Dakota
|
||||
ND
|
||||
Bismarck
|
||||
762,062
|
||||
70,698
|
||||
Nebraska
|
||||
NE
|
||||
Lincoln
|
||||
1,934,408
|
||||
77,348
|
||||
New Hampshire
|
||||
NH
|
||||
Concord
|
||||
1,359,711
|
||||
9,349
|
||||
New Jersey
|
||||
NJ
|
||||
Trenton
|
||||
8,882,190
|
||||
8,723
|
||||
New Mexico
|
||||
NM
|
||||
Santa Fe
|
||||
2,096,829
|
||||
121,590
|
||||
Nevada
|
||||
NV
|
||||
Carson City
|
||||
3,080,156
|
||||
110,572
|
||||
New York
|
||||
NY
|
||||
Albany
|
||||
19,453,561
|
||||
54,555
|
||||
Ohio
|
||||
OH
|
||||
Columbus
|
||||
11,689,100
|
||||
44,826
|
||||
Oklahoma
|
||||
OK
|
||||
Oklahoma City
|
||||
3,956,971
|
||||
69,899
|
||||
Oregon
|
||||
OR
|
||||
Salem
|
||||
4,217,737
|
||||
98,379
|
||||
Pennsylvania
|
||||
PA
|
||||
Harrisburg
|
||||
12,801,989
|
||||
46,054
|
||||
Rhode Island
|
||||
RI
|
||||
Providence
|
||||
1,059,361
|
||||
1,545
|
||||
South Carolina
|
||||
SC
|
||||
Columbia
|
||||
5,148,714
|
||||
32,020
|
||||
South Dakota
|
||||
SD
|
||||
Pierre
|
||||
884,659
|
||||
77,116
|
||||
Tennessee
|
||||
TN
|
||||
Nashville
|
||||
6,829,174
|
||||
42,144
|
||||
Texas
|
||||
TX
|
||||
Austin
|
||||
28,995,881
|
||||
268,596
|
||||
Utah
|
||||
UT
|
||||
Salt Lake City
|
||||
3,205,958
|
||||
84,897
|
||||
Virginia
|
||||
VA
|
||||
Richmond
|
||||
8,535,519
|
||||
42,775
|
||||
Vermont
|
||||
VT
|
||||
Montpelier
|
||||
623,989
|
||||
9,616
|
||||
Washington
|
||||
WA
|
||||
Olympia
|
||||
7,614,893
|
||||
71,298
|
||||
Wisconsin
|
||||
WI
|
||||
Madison
|
||||
5,822,434
|
||||
65,496
|
||||
West Virginia
|
||||
WV
|
||||
Charleston
|
||||
1,792,147
|
||||
24,230
|
||||
Wyoming
|
||||
WY
|
||||
Cheyenne
|
||||
578,759
|
||||
97,813
|
BIN
3rd-Semester-Fall-2022/PDS/Homework06/build/a.out
Executable file
BIN
3rd-Semester-Fall-2022/PDS/Homework06/build/a.out
Executable file
Binary file not shown.
1
3rd-Semester-Fall-2022/PDS/Homework06/build/src/HW06_Aidan_Sharpe.cpp.d
Executable file
1
3rd-Semester-Fall-2022/PDS/Homework06/build/src/HW06_Aidan_Sharpe.cpp.d
Executable file
@ -0,0 +1 @@
|
||||
build/./src/HW06_Aidan_Sharpe.cpp.o: src/HW06_Aidan_Sharpe.cpp
|
BIN
3rd-Semester-Fall-2022/PDS/Homework06/build/src/HW06_Aidan_Sharpe.cpp.o
Executable file
BIN
3rd-Semester-Fall-2022/PDS/Homework06/build/src/HW06_Aidan_Sharpe.cpp.o
Executable file
Binary file not shown.
69
3rd-Semester-Fall-2022/PDS/Homework06/src/HW06_Aidan_Sharpe.cpp
Executable file
69
3rd-Semester-Fall-2022/PDS/Homework06/src/HW06_Aidan_Sharpe.cpp
Executable file
@ -0,0 +1,69 @@
|
||||
/****************************************************************
|
||||
* Name: Aidan Sharpe
|
||||
* Course: Principles of Data Structures
|
||||
* Class: CS04225
|
||||
* Assignment Date: November 07, 2022
|
||||
* File Name: HW06_Aidan_Sharpe.cpp
|
||||
*****************************************************************
|
||||
* ID: Homework 6 Problem 1
|
||||
* Purpose: Read state info data into and out of maps
|
||||
*****************************************************************/
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
struct state{
|
||||
std::string name, abrreviation, capitol;
|
||||
int population, area;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
std::ifstream infile;
|
||||
std::map<std::string, state> stateInfo;
|
||||
infile.open("StatesInfo.txt");
|
||||
|
||||
// parse state info into a map
|
||||
for (int i=0; i<50; i++)
|
||||
{
|
||||
state s;
|
||||
std::getline(infile, s.name);
|
||||
std::getline(infile, s.abrreviation);
|
||||
std::getline(infile, s.capitol);
|
||||
std::string temp;
|
||||
std::getline(infile, temp);
|
||||
temp.erase(std::remove(temp.begin(), temp.end(), ','), temp.end()); // remove commas
|
||||
s.population = std::stoi(temp);
|
||||
std::getline(infile, temp);
|
||||
temp.erase(std::remove(temp.begin(), temp.end(), ','), temp.end()); // remove commas
|
||||
s.area = std::stoi(temp);
|
||||
|
||||
stateInfo.emplace(s.abrreviation, s); // add state to state info; state referenced by abbreviation
|
||||
}
|
||||
|
||||
bool quit = false;
|
||||
std::string abbr;
|
||||
|
||||
// query state info from shell
|
||||
while (true)
|
||||
{
|
||||
std::cout << "Enter a U.S. State Abbreviation or 'Q' to quit.\n";
|
||||
std::cin >> abbr;
|
||||
if (abbr == "Q" || abbr == "q")
|
||||
break;
|
||||
if (stateInfo.count(abbr))
|
||||
{
|
||||
std::cout << "Name: " << stateInfo[abbr].name << '\n';
|
||||
std::cout << "Abbreviation: " << stateInfo[abbr].abrreviation << '\n';
|
||||
std::cout << "Capitol: " << stateInfo[abbr].capitol << '\n';
|
||||
std::cout << "Population: " << stateInfo[abbr].population << '\n';
|
||||
std::cout << "Area: " << stateInfo[abbr].area << " square miles\n";
|
||||
}
|
||||
else
|
||||
std::cout << "Not a valid U.S. State Abbreviation.\n";
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user