Помогите с программой.

  • Автор темы Qwirter
  • Дата начала
Статус
Закрыто для дальнейших ответов.
Q

Qwirter

Гость
#1
Задали на курсовой написать программу в С++ Builder на обработку дат. Написал программу "Вычисление нерабочих дней в месяце", а закоментировать не могу. Помогите пожалуйста...

Unit1.cpp

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#define MaxNerDn 9
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
TDateTime d[2];
int i;
double dd;
OutOfWork(TDateTime dt1,TDateTime dt2)
{
int VixPr[12][MaxNerDn]={1,2,5,7,8,9,16,23,30,
6,13,20,27,0,0,0,0,0,
6,13,20,27,0,0,0,0,0,
3,10,17,24,0,0,0,0,0,
1,8,9,15,22,29,0,0,0,
5,12,19,26,0,0,0,0,0,
3,10,17,24,31,0,0,0,0,
7,14,21,28,0,0,0,0,0,
4,11,18,25,0,0,0,0,0,
2,9,16,23,30,0,0,0,0,
6,13,20,27,0,0,0,0,0,
4,11,18,25,0,0,0,0,0,}; //Календарь на 2011г.
int LastDaysOfMonth[]={31,28,31,30,31,30,31,31,30,31,30,31};
Word y1,m1,d1,y2,m2,d2;
DecodeDate(dt1,y1,m1,d1);
DecodeDate(dt2,y2,m2,d2);
int i=0, ii=0,jj=0,p,j=0;
if(m1==m2)
{
for(i=0,ii=0,jj=0;i<MaxNerDn;i++)
{
p=VixPr[m1-1];
if(p>0 && p>=d1 && p<=d2)
ii++;}
}
else
{
for(i=0,ii=0;i<MaxNerDn;i++)
{
p=VixPr[m1-1];
if(p>0 && p>=d1 && p <= LastDaysOfMonth[m1-1])
ii++;
}
for(j=0,jj=0;j<MaxNerDn;j++)
{
p=VixPr[m2-1][j];
if(p>0 && p>=1 && p<=d2)
jj++;
}
}
return(ii+jj);
}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
static int j=0;
if(j!=100)
{

Edit1->Text="";
j=100;
return;
}
int k=OutOfWork(d[0],d[1]);
Edit1->Text=IntToStr(k);

j=101;
i=0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
i=0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::DateTimePicker1CloseUp(TObject *Sender)
{
d=DateTimePicker1->Date;
i++;
d=dd;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
Form1->Hide();
Form2->Show();
}
//---------------------------------------------------------------------------


Unit1.h

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm

{
__published: // IDE-managed Components
TEdit *Edit1;
TDateTimePicker *DateTimePicker1;
TButton *Button3;
void __fastcall DateTimePicker1CloseUp(TObject *Sender);
void __fastcall Button1Click(TObject *Sender);
void __fastcall Button2Click(TObject *Sender);
void __fastcall Button3Click(TObject *Sender);
private: // User declarations
public: // User declarations

__fastcall TForm1(TComponent* Owner);

};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif


Unit2.cpp

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "Unit2.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm2::OKButtonClick(TObject *Sender)
{
Form2->Close();
Form1->Show();
}
//---------------------------------------------------------------------------


Unit2.h

//---------------------------------------------------------------------------

#ifndef Unit2H
#define Unit2H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
//---------------------------------------------------------------------------
class TForm2 : public TForm
{
__published: // IDE-managed Components
TButton *OKButton;
TPanel *Panel1;
TImage *ProgramIcon;
TLabel *ProductName;
TLabel *Version;
TLabel *Comments;
TLabel *Label1;
TLabel *Label2;
TLabel *Label3;
void __fastcall OKButtonClick(TObject *Sender);
private: // User declarations
public: // User declarations
__fastcall TForm2(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm2 *Form2;
//---------------------------------------------------------------------------
#endif


http://s007.radikal.ru/i301/1103/90/64b3e5d6b82c.jpg
 
Статус
Закрыто для дальнейших ответов.