I need a c++ code that:
1- Read from a text file using C++ example: mytext.txt
2- a function that adds three letters to each latter in that text file
for example, if there is a "hello world" inside the text file
the function will make it look like "habcezyeloiulghtoiuy wnfroewqrmnilkitduyt" if you note the first latter h follow with three letters abc the e follow with another three zye .... etc
so the function is like hashing function that adds for each latter another three letters. print the hashing in this function in main.
3- a function that gives me the solution for the first function and prints the solve for the hashing which is the info inside the text file in the main.
example: hello" h---e---l---l---o--- print h then delete the other three letters then print e then delete the other three letters ...etc at final it will look like original word inside the text file "hello".
the text file could include sentences no limit.
Please find the answer below:
```
#include <bits/stdc++.h>
using namespace std;
const int MAX = 26;
string addRandomString(int n)
{
char alphabet[MAX] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z' };
string res = "";
for (int i = 0; i < n; i++)
res = res + alphabet[rand() % MAX];
return res;
}
string getOriginalText (string hashedText) {
string originalText = "";
for (int i=0; i<hashedText.length() && i%4 == 0;
++i)
{
originalText = originalText + hashedText.at(i);
}
return originalText;
}
int main()
{
srand(time(NULL));
string hashedText = "";
char ch;
fstream fin("mytext.txt", fstream::in);
while (fin >> noskipws >> ch) {
hashedText = hashedText + ch + addRandomString(3) ;
}
cout << "Hashed Text " << hashedText << endl;
cout << "Original Text " << getOriginalText(hashedText) << endl;
return 0;
}
```
Hope this helps!
I need a c++ code that: 1- Read from a text file using C++ example: mytext.txt...
JAVA Code: Complete the program that reads from a text file and counts the occurrence of each letter of the English alphabet. The given code already opens a specified text file and reads in the text one line at a time to a temporary String. Your task is to go through that String and count the occurrence of the letters and then print out the final tally of each letter (i.e., how many 'a's?, how many 'b's?, etc.) You can...
I need help building a program on microsoft visual studio using c++ language. implement a program called "charword_freq.cpp" to determine the number of words and the number of occurrences of each letter in a block of text stored in a data file called “mytext.dat”. Define a word to be any string of letters that is delimited at each end by either whitespace, a period, a comma, or the beginning or end of a line. You can assume that the input...
According to Wikipedia , a comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. A CSV file stores tabular data (numbers and text) in plain text. Each line of the file is a data record. Each record consists of one or more fields, separated by commas. The use of the comma as a field separator is the source of the name for this file format. A company has text data that is not...
USING C LANGUAGE Write a program to compute a Caesar Cipher . You must read in a file of text and convert some of the letters to another letter using the following array: char key[27] = “efghijklmnopqrstuvwxyzabcd”; This means that if you encounter the letter ‘a’, then you will replace it with the letter ‘e’,etc. If you encounter any other characters in the input file (example: ‘A’ or space, etc, you will write them as is. You will write each...
I need help parsing a large text file in order to create a map using Java. I have a text file named weather_report.txt which is filled with hundreds of different indexes. For example: one line is "POMONA SUNNY 49 29 46 NE3 30.46F". There are a few hundred more indexes like that line with different values in the text file and they are not delimited by commas but instead by spaces. Therefore, in this list of indexes we only care...
The following code uses a Scanner object to read a text file called dogYears.txt. Notice that each line of this file contains a dog's name followed by an age. The program then outputs this data to the console. The output looks like this: Tippy 2 Rex 7 Desdemona 5 1. Your task is to use the Scanner methods that will initialize the variables name1, name2, name3, age1, age2, age3 so that the execution of the three println statements below will...
I need help writing this C code. Here is the description: Let's say we have a program called smart typing which does two things: The first letter of a word is always input manually by a keystroke. When a sequence of n letters has been typed: c1c2...cn and the set of words in the dictionary that start with that sequence also have c1c2...cnc then the smart typing displays c automatically. we would like to know, for each word in the dictionary,...
Please Only use C language In this assignment, you have to read a text file (in.txt) that contains a set of words. The first line of the file contains 3 numbers (N, S, D). These numbers represent the sequence of input words in your file. N: represents the number of words to read to build a binary search tree. You have to write a recursive insert code to create and insert these words into the binary search tree. After inserting...
Please write a c++ header file, class implementation file and
main file that does all of the following and meets the requirements
listed below. Also include a Output of your code as to show that
your program works and functions properly.
EXERCISING A DOUBLY-LINKED LIST CLASS
This project consists of two parts, the second of which appears
below. For the first part, write a class that
implements an unordered list abstract data type
using a doubly-linked list with pointers to...
I am having a little trouble with my Python3 code today, I am
not sure what I am doing wrong. Here are the instructions:
and here is my code:
update: I have seen I did not close x in sumFile and I am still
only getting a 2/10 on the grader. any help appreciated.
Lab-8 For today's lab you going to write six functions. Each function will perform reading and/or write to a file Note: In zybooks much like on...