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?
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);
}
}
#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);
}
}
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?
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.
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
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....
if array has to have at least one element, etc....
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?
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::ou t);
while((c=Outfile.get()) != EOF)
{
if((c=='y')||(c=='Y'))
{ outfile.seekp(-sizeof(c),i os::cur);
Outfile.put('k');
}
}
}
Hope this will help U
Sisu
Use the followinf code
void main()
{
char c;
fstream Outfile("output.txt",ios::
while((c=Outfile.get()) != EOF)
{
if((c=='y')||(c=='Y'))
{ outfile.seekp(-sizeof(c),i
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!
ASKER
I'm not looking for a program.
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
k thanx
how do I get points or award pints>?
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).
#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');
}
}