Click here to Skip to main content
15,896,329 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
The general call to the executable is as follow in Linux:
./main input=input31.txt output=output31.txt
The input file and the outputted result should fulfill the following requirements.
1) Like above command shows, two arguments will be given when running your
program.
2) The first argument means the file that contains numbers is input31.txt. The second
argument means your output file name is output31.txt.
3) All the input and output file names are changing depend on different test cases.
4) When reading the input file, you should go through each character and form the
actual number.
5) A number may have three different forms: 1. Number, ranging from 0 to 9. 2.Numbers in words, ranging from zero to nine, without spaces in between, are in lower case, ending with a “word”. 3. Numbers with addition/subtraction, ranging from 0 to 9, result from 0 to 9, numbers and operator separated with space(s). All the numbers are meaningful without error.
6) Each line contains one form of number, one form of number contained in one line.
7) The output file contains “match” or “not match” (case sensitive). If all the numbers
equal to each other, you should output “match”, otherwise output “not match”.

What I have tried:

lang="c++">
#include<iostream>
#include<fstream>
#include<cstring>
#include "ArgumentManager.h"

using namespace std;

int main(int argc, char **argv)
{
  ifstream fin;
  ofstream fout;
  ArgumentManager am(argc, argv, ' ');
  string inputFileName = am.get("inout");
  string outputFileName = am.get("output");
  fin.open(inputFileName.c_str());
  fout.open(outputFileName.c_str());
  char ch;
  cin ch;
  
}
Posted
Updated 19-Jun-20 17:46pm

1 solution

Where are you stuck ? this isnt a code-to-order site ...

Maybe you would want to think about reading characters from the file .. this might be a start for part 4 of your question
while (fin >> noskipws >> ch) {
    // do something with ch 
}
now you need to start doing something with the characters read into 'ch', as per part 5, ie, you need to check if they are digits 0..9, letters making words (and then do those words make a number) etc and include a check for 'carriage-return' aka end of line.


I'd start simply - 1st pass, just be able to read the characters and 'classify' them - digit, letter etc, 2nd pass - group digits or letters and do something with the groups when end-of-line is detected, and keep up building your program bit by bit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900