Link to home
Start Free TrialLog in
Avatar of q_low
q_low

asked on

Algorithm

I want to develop an algorithm that solves the Y2k problem by changing all the y's to k's in a documents.(can be assumed that a document is merely and array of characters) What are good especifications for it?
Avatar of snifong
snifong
Flag of United States of America image


#include <fstream.h>
#include <iostream.h>

void main()
{
char c;
ifstream Infile("input.txt", ios::in);
ofstream Outfile("output.txt", ios::out);
   while((c=Infile.get()) != EOF) {
      if((c=='y')||(c=='Y'));
            Outfile.put('k');
   }
}
Sorry.  This is a little different.  It writes to another file.
#include <fstream.h>
#include <iostream.h>

void main()
{
char c;
ifstream Infile("input.txt", ios::in);
ofstream Outfile("output.txt", ios::out);
   while((c=Infile.get()) != EOF) {
      if((c=='y')||(c=='Y'));
         Outfile.put('k');
      else
         Ouputfile.put(c);
   }
}
Avatar of q_low
q_low

ASKER

What about specifications?
We cannot provide answers to school assignments.  That is grounds for removal from this site.  (for both you and the experts involved.)  We can provide only limitied help in accademic assignments.    We can answer specific (direct) questions, like you might ask your teacher.  We can review your work and post suggestions, again, like your teacher might do.

Do you have specific questions?
Do you have any work on this (incomplete even) that we can review?
Post a few of the ones that you think should be there and then let us look at them and help you out where you are stuck.
Avatar of q_low

ASKER

nietod...this is no school assigment if you are learning this by yourself. So i make it clear it ain't an assigment. As far as code is concern, I'm working on it again to post it so you can give me a better help, had a pc crashed and had to get a new disk so i don't have my program.Thanx
Avatar of q_low

ASKER

What I meant by specifications in the question was meant to be like this:
if array has to have at least one element, etc....
Avatar of q_low

ASKER

Not what i asked for. I asked by specifications not a program
What do you mean by specifications?  And why do you need them?
Avatar of q_low

ASKER

Well to have some idea what i got to do in the problem.I feel it is too ambiguous. So I am asking you what do I have to take in consideration to make the program.
What do you have so far?
Hi,
  Use the followinf code

void main()
{
char c;
fstream Outfile("output.txt",ios::in|ios::out);
   while((c=Outfile.get()) != EOF)
   {
      if((c=='y')||(c=='Y'))
      {  outfile.seekp(-sizeof(c),ios::cur);
         Outfile.put('k');
      }
    }
}
Hope this will help U

Sisu
SISU, have you read the question history?  You can't answer a question unless you've read it!
Avatar of q_low

ASKER

I'm not looking for a program.
Avatar of q_low

ASKER

Will these be good specifications?
1. array >0
2. at least there should be one y in the array
3.return array with y's changed with k's
ASKER CERTIFIED SOLUTION
Avatar of nietod
nietod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of q_low

ASKER

k thanx
how do I get points or award pints>?
You need to pick the expert that you think helped the most and either ask them to submit an answer or you can accept one of their comments as an answer (this option appears at the top of the comment box).