码迷,mamicode.com
首页 > 编程语言 > 详细

homework No. 1: Arrays, struct, and functions C++程序

时间:2015-02-17 14:04:03      阅读:1088      评论:0      收藏:0      [点我收藏+]

标签:

霸渣编程 服务编号:cplus00044

Problem description:

  • Problem 1. Implement a C++ program that has the following functions:
    1. Reads in a paragraph of English text up to 100 words from the keyboard and stores this paragraph in a string object. Feel free to include this task in the main() function.
    2. Identifies the least frequent letter (case insensitive) in the above paragraph. Implement a separate function getLeastFreqLetter() for this task. The main() function then calls this function to find out the least frequent letter and its frequency.
    3. Calculate the frequency of each unique word (case insensitive). Implement another function countWordFreq() for this task. Use white spaces and punctuation marks such as comma, period, semicolon and question mark as word delimiters. Please define a global struct that contains two fields, word and its count for this task. You can then define an array of this struct to store all the unique words and its counts. The main() function will call this function to print out each word and its corresponding frequency.
    4. Identify the most frequently occurring word in the paragraph. Implement another stand-alone function getMostFreqWord() for this purpose. This function will be called in main() to identify the most frequent word and its respective frequency.

Please provide a simple yet flexible user interface so other people can use & test your program.

  • Problem 2: Implement another C++ program to sort a list of integers using the selection sort algorithm. You are required to
    1. use an integer vector to store the input numbers typed from the keyboard. The declaration of this vector will be in main(). You‘ll need to implement a separate function readData() to read numbers from the keyboard;
    2. implement a separate function called selectionSort(), which will be called by the main() function to sort the afore-mentioned vector;
    3. implement another function printVector() to print out the content of the vector. This function will be called by main() right after calling readData() and selectionSort(), respectively, to print out the vector content before and after being sorted.

Submission instructions: Submit a single zip file together with other documenting files as specified in the "Homework: what to submit on iLearn?" document by the due time. This document is posted on the top panel of the iLearn website.

homework No. 1: Arrays, struct, and functions C++程序

标签:

原文地址:http://www.cnblogs.com/goodvsbad/p/4295198.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!