Hello Everybody.I need to write a C++ program(block letters via functions)
Firstly, write a function
void line( char ch, int num)
which outputs the character ch num times in a row on a given line.
Secondly, write a function
void rectangle (char ch, int x, int y)
which writes the character ch in a rectangular pattern of x rows and y columns.
Thirdly, write a main body to read one character at a time from animals.dat.Th eprogram should produce a rectangular pattern for each letter in the animals name; the size of the rectangular pattern depends on the letter and on its position in the animal name, the rule being: if the x th letter in the name is the y th letter of the alphabet, the rectangle should be size x by y.
This is what i got so far . Thank you for the help
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#include iostream
#include fstream
void line(char ch, int num);
void rectangle(char ch, int x, int num);
using namespace std;
ifstream fin;
ofstream fout;
void line(char ch, int num)
{
for(int i=1, i<=x,i++)
{
cout<<ch
fout<<ch
}
}
cout<<endl;
fout<<endl;
void rectangle (char ch , int, int y)
{
line(ch,int num);
}
for(int j=1, j=y, j++)
{
cout<<endl<<endl;
fout<<endl<<endl;
}
int main()
{
fin.open("animals.dat");
int i,j;
for(int j=1, j=y, j++)
{
cout<<endl<<endl;
cout<<endl<<endl;
}
return 0;
}
|