T
tomakated
How can I get the dashes and numbers to line up with the dashes above<?.
Want all the "|" to line up and all the Numbers to line up<?
and also how can I get rid of the last line of "---" and the last line of
"|" in the program<?.
#include <iostream>
#include <iomanip>
void calendar (int,int) ;
void printweek (int,int) ;
void lineofdashes() ;
void linewithnumbers(int, int) ;
void linewithoutnumbers();
const int Boxwidth = 7;
const int Boxheight = 4;
int main()
{
calendar (1,9) ;
}
void calendar (int startday, int daysinmonth)
{
int first;
first = startday;
while (first<=daysinmonth)
{
printweek (first, daysinmonth);
first=first+3;
}
linewithoutnumbers();
}
void printweek (int first, int daysinmonth)
{
int i;
linewithoutnumbers ();
linewithoutnumbers ();
linewithnumbers (first, daysinmonth);
for (i=0; i<Boxheight-3; i++)
lineofdashes ();
}
void lineofdashes()
{
int i;
for (i=0; i<3*Boxwidth + 5; i++)
cout << "-";
cout << endl;
}
void linewithoutnumbers()
{
int i;
for (i=0; i<3; i++)
cout << setw(Boxwidth+1) << "|";
cout << endl;
}
void linewithnumbers (int first, int daysinmonth)
{
int i, boxnumber;
boxnumber = first;
for (i=0; i<3; i++)
{
if ((boxnumber >0) && (boxnumber <= daysinmonth))
cout << setw(Boxwidth-1) << boxnumber << "|";
else cout << setw(Boxwidth+1) << "|";
boxnumber ++;
}
cout << endl;
"calendar.cpp" 71 lines, 1164 characters
$ g++ calendar.cpp -o calendar.out
$ calendar.out
| | |
| | |
1| 2| 3|
Want all the "|" to line up and all the Numbers to line up<?
and also how can I get rid of the last line of "---" and the last line of
"|" in the program<?.
#include <iostream>
#include <iomanip>
void calendar (int,int) ;
void printweek (int,int) ;
void lineofdashes() ;
void linewithnumbers(int, int) ;
void linewithoutnumbers();
const int Boxwidth = 7;
const int Boxheight = 4;
int main()
{
calendar (1,9) ;
}
void calendar (int startday, int daysinmonth)
{
int first;
first = startday;
while (first<=daysinmonth)
{
printweek (first, daysinmonth);
first=first+3;
}
linewithoutnumbers();
}
void printweek (int first, int daysinmonth)
{
int i;
linewithoutnumbers ();
linewithoutnumbers ();
linewithnumbers (first, daysinmonth);
for (i=0; i<Boxheight-3; i++)
lineofdashes ();
}
void lineofdashes()
{
int i;
for (i=0; i<3*Boxwidth + 5; i++)
cout << "-";
cout << endl;
}
void linewithoutnumbers()
{
int i;
for (i=0; i<3; i++)
cout << setw(Boxwidth+1) << "|";
cout << endl;
}
void linewithnumbers (int first, int daysinmonth)
{
int i, boxnumber;
boxnumber = first;
for (i=0; i<3; i++)
{
if ((boxnumber >0) && (boxnumber <= daysinmonth))
cout << setw(Boxwidth-1) << boxnumber << "|";
else cout << setw(Boxwidth+1) << "|";
boxnumber ++;
}
cout << endl;
"calendar.cpp" 71 lines, 1164 characters
$ g++ calendar.cpp -o calendar.out
$ calendar.out
| | |
| | |
1| 2| 3|