Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Download the file USDictionary.txt from the course Blackboard site that contains

ID: 3713157 • Letter: D

Question

Download the file USDictionary.txt from the course Blackboard site that contains words in the US dictionary (about 118,000 words – all in lower case). Write a C++ program that will determine and display the following items:

The total number of words in the dictionary.

The total number of characters in the dictionary (not including white spaces)

The total number of characters in the dictionary (including white spaces) – Hint: Use get( ).

The total number of words ending in the letter e.

The total number of 6 letter words.

The total number of words beginning with a vowel.

The total number of words containing the substring “ate”.

The total number of occurances of the letter e.

The total number of words containing at least two occurances of the letter e.

      Turn in a printout of the program and the results.

Explanation / Answer

#include "stdafx.h"

#include <stdio.h>

#include <string>

#include <stdlib.h>

#include <fstream>

#include <iostream>

using namespace std;

#pragma warning(disable : 4996)

int k;

char output[100][100];

//char **output;

int factorial(int n)

{

if (n<=1){

return 1;

}

else

return n*factorial(n-1);

}

/*

void print(char *v, const int n){

//sprintf(output[k++],"%s",v);

//strcpy(output[k],v);

//k++;

}

*/

void permute(char *v, const int start, const int n)

{  

if (start == n-1) {

//print(v,n);

sprintf(output[k++],"%s",v);

  

}

else {

for (int i = start; i < n; i++) {

int tmp = v[i];

  

v[i] = v[start];

v[start] = tmp;

permute(v, start+1, n);

v[start] = v[i];

v[i] = tmp;

}

}

}

void dictionary(int m)

{

ifstream infile("dictionary.txt");

string *list= new string[267751];

//char list[267751][5];

//string list[267751];

if (infile.is_open()){

for (int i=0; i <267751; i++)

{

//infile>>list[i];

getline(infile, list[i]);

//cout<<list[i]<<endl;

}

}

infile.close();

for (int i=0; i<267751; i++)

{

for (int j=0; j<m; j++)

{

if(output[j]==list[i])

{

printf("Spelling suggestions: %s ", list[i]);

}

}

}

}

int main()

{

//read in word

char word[100];

printf ("Enter a word: ");

scanf("%s",word);

int n=strlen(word);

int i,m=factorial(n);

for(int j=0; j<n; j++)

{

word[j]=toupper(word[j]);

}

//generate permutations of the word

//char** output=(char**)malloc(m*sizeof(char*));

//for (i=0; i<m; i++){

//output[i]=(char*)malloc((n+2)*sizeof(char));

//}

k=0;

permute(word,0,n);

for (i=0; i<m; i++){

printf("%d %s ",i,output[i]);

}

//for each word in the permutation list, search it in the dictionary. if match, store in an output array

dictionary(m);

//give names for output

system("pause");

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote