正在加载图片...
-11- Problem 8-Data structure design(15 points) One of the best sources of data about the nations of the world is the CA World Factbook,a comprehensive compendium of public-domain information available on the web as http://www.odei.gov/cia/publications/factbook.The Factbook includes data on 266 countries,ranging alphabetically from Afghanistan to Zimbabwe. For this problem,your job is to design a database that can keep track of a small subset of this information.For each country in the world,you need to maintain the following information: The name of the country The name of the capital city The geographic area in square kilometers ·The population A list of the major ethnic groups and the percentage each comprises of the population As an example,the data you would need to represent for Afghanistan looks like this: Name: Afghanistan Capital: Kabul Area: 647,500 Population: 24,792,375 Ethnic groups: Pashtun 38% Tajik 25% Hazara 19% Uzbek 6% Other 12% As a second example,the data for Turkey looks like this: Name: Turkey Capital: Ankara Area: 780,580 Population: 64,566,511 Ethnic groups: Turkish 80% Kurdish 20% 8a)Design a set of data structure definitions that make it possible to represent the small subset of the World Factbook described above.In particular,you need to write a typedef statement(presumably along with other typedef statements that introduce subsidiary types) that defines a type factbookDB capable of maintaining the required information.In writing your data definitions,you should make the following assumptions: There will never be more than 500 countries in the database. The area may not be a whole number.The area of Vatican City,for example,is only 0.44 square kilometers. The population will certainly not fit into an integer word on some machines.You may, however,assume that the population fits in a value of type long. There will never be more than 20 ethnic groups listed for any country. Solution space for Problem 8a is on the next page.– 11 – Problem 8—Data structure design (15 points) One of the best sources of data about the nations of the world is the CIA World Factbook, a comprehensive compendium of public-domain information available on the web as http://www.odci.gov/cia/publications/factbook. The Factbook includes data on 266 countries, ranging alphabetically from Afghanistan to Zimbabwe. For this problem, your job is to design a database that can keep track of a small subset of this information. For each country in the world, you need to maintain the following information: • The name of the country • The name of the capital city • The geographic area in square kilometers • The population • A list of the major ethnic groups and the percentage each comprises of the population As an example, the data you would need to represent for Afghanistan looks like this: Name: Afghanistan Capital: Kabul Area: 647,500 Population: 24,792,375 Ethnic groups: Pashtun 38% Tajik 25% Hazara 19% Uzbek 6% Other 12% As a second example, the data for Turkey looks like this: Name: Turkey Capital: Ankara Area: 780,580 Population: 64,566,511 Ethnic groups: Turkish 80% Kurdish 20% 8a) Design a set of data structure definitions that make it possible to represent the small subset of the World Factbook described above. In particular, you need to write a typedef statement (presumably along with other typedef statements that introduce subsidiary types) that defines a type factbookDB capable of maintaining the required information. In writing your data definitions, you should make the following assumptions: • There will never be more than 500 countries in the database. • The area may not be a whole number. The area of Vatican City, for example, is only 0.44 square kilometers. • The population will certainly not fit into an integer word on some machines. You may, however, assume that the population fits in a value of type long. • There will never be more than 20 ethnic groups listed for any country. Solution space for Problem 8a is on the next page
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有