ハルhal
デジタル コンテンツ

pc2

作って学ぶ
ハードとソフト

アルゴリズム
電子回路

 






このサイトはHPです
ブログではありません
要望・意見は
下記の掲示場を利用して
下さいまたブログも見て下さい

 

ロボット・DOSV掲示板兼Blog

懐かしのコンピュータ
Apple II Apple2
PC9801 PC9821

roboto

Topに戻る

ララ Lara
アナログ コンテンツ

Lara座れ
動画で学ぶ
躾と訓練
動画メニュー


工作


集団練習メニュー


しつけ 訓練コラム




最後にララについて

このサイトはHPです
ブログではありません
要望・意見は
下記の掲示場を利用して
下さいまたブログも見て下さい

Laraララの
ブログ

犬のしつけと訓練
掲示板


掲示板の利用規則

 

 

 

 

Lara伏せ
Topに戻る
松本 ワンワンクラブ
わんわんクラブ

 

Visual Studio 2008 Express Edition でバイオリズム(biorhythm)を作ろう
 

日数計算の公式を利用してみる
フリーゲルの公式 Zellerの公式 等(wikiより)

��Visual Studio 2008 Express Editioを起動します

��Windowsフォームアプリケーションを選択します。
適当な名前をつけます。ここではbiorとしました。

��線画の準備のためペイントをセットします。
新しくできたホームの右クリックをします。プロパティを選択して雷マークをクリックし「プロパティ」「表示」「ペイント」とすすめます。
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {}
が自動作成されます。ここにバイオリズムのグラフを書きます。

��Formにコントロールを配置します。
ここではコマンドボタン1とテキストボックス1−6を使用します。

�ゥ侫�ームをクリックして
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {}を作成しておきます。

パブリックに静的変数を設定
格差婦プログラムからこの変数がアクセス可能になります。

static int fYear,fMonth,fDay,eYear,eMonth,eDay;
     static int day,day1,day2,day3;

その他 重要事項

1)グラフィックの設定
Graphics^ 変数名=e->Graphics;
例 Graphics^ gr=e->Graphics;

gr->FillRectangle(Brushes::Red,x1+xx,yy-y1,1,1);

2)Invalidate(); //再線画されます

��stdfax.hにsin等を使用するため数学的関数をセットします。

#include <math.h>
#include <time.h>

�Г海海濃藩僂靴申斗廚粉愎�

1)点を打つ(本来は四角を書く)
gr->FillRectangle(Brushes::色,x軸,y軸,幅,高);
例 gr->FillRectangle(Brushes::Red,x1+xx,yy-y1,1,1); ..1,1が点になる

2)線を引く
gr->DrawLine(Pens::色, x始点,y始点,x終点,y終点);

例 gr->DrawLine(Pens::Black, xx,yy-100,xx,yy+100);

3)フォントの設定
System::Drawing::Font^ font1=gcnew System::Drawing::Font("MS ゴシック",サイズ);
例 System::Drawing::Font^ font1=gcnew System::Drawing::Font("MS ゴシック",11);

4)グラフィックとして文字を書く
gr->DrawString("文字列",font1,Brushes::色,x位置,y位置);
例 gr->DrawString("測定年の 日数=",font1,Brushes::Black,10,360);

�┘丱ぅ�リズム
各リズムは誕生日を基準とする同じ振幅の正弦波SINとして表され、身体リズムは23日、感情リズムは28日、知性リズムは33日の周期で変化する。
まず、生まれてから本日(測定日)までの日数を出す。その日数から角度を求める。1周期は360°なので360を23などで割り、日数掛けると測定日までの角度が求まる。この角度をラジアンにする。
式 360÷23×生きている日数×円周率/180

赤字が記入したもの
茶色は自動作成されたもの

 


#pragma once
namespace bior {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;

/// <summary>
/// Form1 の概要
///
/// 警告: このクラスの名前を変更する場合、このクラスが依存するすべての .resx ファイルに関連付けられた
/// マネージ リソース コンパイラ ツールに対して 'Resource File Name' プロパティを
/// 変更する必要があります。この変更を行わないと、
/// デザイナと、このフォームに関連付けられたローカライズ済みリソースとが、
/// 正しく相互に利用できなくなります。
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: ここにコンストラクタ コードを追加します
//
}

private: System::Windows::Forms::TextBox^ textBox7;
public:
static int fYear=1945; //原爆投下日
static int fMonth=8;
static int fDay=6;
static int eYear=2009; //プログラム作成日 23511
static int eMonth=12;
static int eDay=19;
static int tYear=1; //
static int tMonth=1;
static int tDay=1;
static int oYear=1; //
static int oMonth=1;
static int oDay=1;
static int youbi1=0;
static int gMonth=31;
static int day,day1,day2,day3,day4,day5,day6;
int Y6,M6,D6;

private: System::Windows::Forms::Label^ label1;
public:
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;

private: System::Windows::Forms::TextBox^ textBox8;
private: System::Windows::Forms::TextBox^ textBox9;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::TextBox^ textBox11;
private: System::Windows::Forms::TextBox^ textBox12;
private: System::Windows::Forms::TextBox^ textBox13;
private: System::Windows::Forms::TextBox^ textBox14;
private: System::Windows::Forms::TextBox^ textBox15;
private: System::Windows::Forms::TextBox^ textBox16;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::TextBox^ textBox17;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ button7;
private: System::Windows::Forms::TextBox^ textBox18;
private: System::Windows::Forms::TextBox^ textBox19;
private: System::Windows::Forms::TextBox^ textBox20;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::TextBox^ textBox21;
private: System::Windows::Forms::Button^ button8;
private: System::Windows::Forms::TextBox^ textBox10;

protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::TextBox^ textBox1;
private: System::Windows::Forms::TextBox^ textBox2;
private: System::Windows::Forms::TextBox^ textBox3;
private: System::Windows::Forms::TextBox^ textBox4;
private: System::Windows::Forms::TextBox^ textBox5;
private: System::Windows::Forms::TextBox^ textBox6;

private:
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッドの内容を
/// コード エディタで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->textBox1 = (gcnew System::Windows::Forms::TextBox());
this->textBox2 = (gcnew System::Windows::Forms::TextBox());
this->textBox3 = (gcnew System::Windows::Forms::TextBox());
this->textBox4 = (gcnew System::Windows::Forms::TextBox());
this->textBox5 = (gcnew System::Windows::Forms::TextBox());
this->textBox6 = (gcnew System::Windows::Forms::TextBox());
this->textBox7 = (gcnew System::Windows::Forms::TextBox());
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->textBox8 = (gcnew System::Windows::Forms::TextBox());
this->textBox9 = (gcnew System::Windows::Forms::TextBox());
this->textBox10 = (gcnew System::Windows::Forms::TextBox());
this->label5 = (gcnew System::Windows::Forms::Label());
this->textBox11 = (gcnew System::Windows::Forms::TextBox());
this->textBox12 = (gcnew System::Windows::Forms::TextBox());
this->textBox13 = (gcnew System::Windows::Forms::TextBox());
this->textBox14 = (gcnew System::Windows::Forms::TextBox());
this->textBox15 = (gcnew System::Windows::Forms::TextBox());
this->textBox16 = (gcnew System::Windows::Forms::TextBox());
this->label6 = (gcnew System::Windows::Forms::Label());
this->textBox17 = (gcnew System::Windows::Forms::TextBox());
this->label7 = (gcnew System::Windows::Forms::Label());
this->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->button7 = (gcnew System::Windows::Forms::Button());
this->textBox18 = (gcnew System::Windows::Forms::TextBox());
this->textBox19 = (gcnew System::Windows::Forms::TextBox());
this->textBox20 = (gcnew System::Windows::Forms::TextBox());
this->label4 = (gcnew System::Windows::Forms::Label());
this->textBox21 = (gcnew System::Windows::Forms::TextBox());
this->button8 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(822, 35);
this->button1->Margin = System::Windows::Forms::Padding(2);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(77, 58);
this->button1->TabIndex = 0;
this->button1->Text = L"計算";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// textBox1
//
this->textBox1->Location = System::Drawing::Point(677, 35);
this->textBox1->Margin = System::Windows::Forms::Padding(2);
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(55, 19);
this->textBox1->TabIndex = 1;
//
// textBox2
//
this->textBox2->Location = System::Drawing::Point(739, 35);
this->textBox2->Margin = System::Windows::Forms::Padding(2);
this->textBox2->Name = L"textBox2";
this->textBox2->Size = System::Drawing::Size(30, 19);
this->textBox2->TabIndex = 2;
//
// textBox3
//
this->textBox3->Location = System::Drawing::Point(782, 35);
this->textBox3->Margin = System::Windows::Forms::Padding(2);
this->textBox3->Name = L"textBox3";
this->textBox3->Size = System::Drawing::Size(22, 19);
this->textBox3->TabIndex = 3;
//
// textBox4
//
this->textBox4->Location = System::Drawing::Point(677, 74);
this->textBox4->Margin = System::Windows::Forms::Padding(2);
this->textBox4->Name = L"textBox4";
this->textBox4->Size = System::Drawing::Size(54, 19);
this->textBox4->TabIndex = 4;
//
// textBox5
//
this->textBox5->Location = System::Drawing::Point(742, 74);
this->textBox5->Margin = System::Windows::Forms::Padding(2);
this->textBox5->Name = L"textBox5";
this->textBox5->Size = System::Drawing::Size(27, 19);
this->textBox5->TabIndex = 5;
//
// textBox6
//
this->textBox6->Location = System::Drawing::Point(782, 74);
this->textBox6->Margin = System::Windows::Forms::Padding(2);
this->textBox6->Name = L"textBox6";
this->textBox6->Size = System::Drawing::Size(22, 19);
this->textBox6->TabIndex = 6;
//
// textBox7
//
this->textBox7->Location = System::Drawing::Point(679, 145);
this->textBox7->Margin = System::Windows::Forms::Padding(2);
this->textBox7->Name = L"textBox7";
this->textBox7->Size = System::Drawing::Size(56, 19);
this->textBox7->TabIndex = 7;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Location = System::Drawing::Point(677, 10);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(41, 12);
this->label1->TabIndex = 8;
this->label1->Text = L"誕生日";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Location = System::Drawing::Point(679, 59);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(41, 12);
this->label2->TabIndex = 9;
this->label2->Text = L"測定日";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Location = System::Drawing::Point(677, 181);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(99, 12);
this->label3->TabIndex = 10;
this->label3->Text = L"誕生してからの日数";
//
// textBox8
//
this->textBox8->Location = System::Drawing::Point(739, 145);
this->textBox8->Name = L"textBox8";
this->textBox8->Size = System::Drawing::Size(30, 19);
this->textBox8->TabIndex = 12;
//
// textBox9
//
this->textBox9->Location = System::Drawing::Point(775, 145);
this->textBox9->Name = L"textBox9";
this->textBox9->Size = System::Drawing::Size(29, 19);
this->textBox9->TabIndex = 13;
//
// textBox10
//
this->textBox10->Location = System::Drawing::Point(810, 145);
this->textBox10->Name = L"textBox10";
this->textBox10->Size = System::Drawing::Size(29, 19);
this->textBox10->TabIndex = 14;
//
// label5
//
this->label5->AutoSize = true;
this->label5->Location = System::Drawing::Point(683, 229);
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(61, 12);
this->label5->TabIndex = 15;
this->label5->Text = L"生れた曜日";
//
// textBox11
//
this->textBox11->Location = System::Drawing::Point(681, 199);
this->textBox11->Name = L"textBox11";
this->textBox11->Size = System::Drawing::Size(158, 19);
this->textBox11->TabIndex = 16;
//
// textBox12
//
this->textBox12->Location = System::Drawing::Point(683, 244);
this->textBox12->Name = L"textBox12";
this->textBox12->Size = System::Drawing::Size(61, 19);
this->textBox12->TabIndex = 17;
//
// textBox13
//
this->textBox13->Location = System::Drawing::Point(774, 244);
this->textBox13->Name = L"textBox13";
this->textBox13->Size = System::Drawing::Size(39, 19);
this->textBox13->TabIndex = 18;
//
// textBox14
//
this->textBox14->Location = System::Drawing::Point(775, 266);
this->textBox14->Name = L"textBox14";
this->textBox14->Size = System::Drawing::Size(38, 19);
this->textBox14->TabIndex = 19;
//
// textBox15
//
this->textBox15->Location = System::Drawing::Point(677, 329);
this->textBox15->Name = L"textBox15";
this->textBox15->Size = System::Drawing::Size(58, 19);
this->textBox15->TabIndex = 20;
//
// textBox16
//
this->textBox16->Location = System::Drawing::Point(741, 329);
this->textBox16->Name = L"textBox16";
this->textBox16->Size = System::Drawing::Size(30, 19);
this->textBox16->TabIndex = 21;
//
// label6
//
this->label6->AutoSize = true;
this->label6->Location = System::Drawing::Point(686, 266);
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(68, 12);
this->label6->TabIndex = 22;
this->label6->Text = L"Zellerの公式";
//
// textBox17
//
this->textBox17->Location = System::Drawing::Point(775, 329);
this->textBox17->Name = L"textBox17";
this->textBox17->Size = System::Drawing::Size(21, 19);
this->textBox17->TabIndex = 23;
//
// label7
//
this->label7->AutoSize = true;
this->label7->Location = System::Drawing::Point(750, 229);
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(113, 12);
this->label7->TabIndex = 24;
this->label7->Text = L"本日曜日からの戻り数";
//
// button2
//
this->button2->Location = System::Drawing::Point(681, 297);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(73, 26);
this->button2->TabIndex = 25;
this->button2->Text = L"最大注意日";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
//
// button3
//
this->button3->Location = System::Drawing::Point(730, 104);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(46, 26);
this->button3->TabIndex = 26;
this->button3->Text = L"本日";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
//
// button4
//
this->button4->Location = System::Drawing::Point(782, 105);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(42, 25);
this->button4->TabIndex = 27;
this->button4->Text = L"翌月";
this->button4->UseVisualStyleBackColor = true;
this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
//
// button5
//
this->button5->Location = System::Drawing::Point(762, 354);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(54, 25);
this->button5->TabIndex = 28;
this->button5->Text = L"注意日";
this->button5->UseVisualStyleBackColor = true;
this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
//
// button6
//
this->button6->Location = System::Drawing::Point(822, 357);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(65, 22);
this->button6->TabIndex = 29;
this->button6->Text = L"次回注意日";
this->button6->UseVisualStyleBackColor = true;
this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
//
// button7
//
this->button7->Location = System::Drawing::Point(681, 358);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(75, 22);
this->button7->TabIndex = 30;
this->button7->Text = L"前回注意日";
this->button7->UseVisualStyleBackColor = true;
this->button7->Click += gcnew System::EventHandler(this, &Form1::button7_Click);
//
// textBox18
//
this->textBox18->Location = System::Drawing::Point(677, 393);
this->textBox18->Name = L"textBox18";
this->textBox18->Size = System::Drawing::Size(57, 19);
this->textBox18->TabIndex = 31;
//
// textBox19
//
this->textBox19->Location = System::Drawing::Point(742, 393);
this->textBox19->Name = L"textBox19";
this->textBox19->Size = System::Drawing::Size(27, 19);
this->textBox19->TabIndex = 32;
//
// textBox20
//
this->textBox20->Location = System::Drawing::Point(775, 393);
this->textBox20->Name = L"textBox20";
this->textBox20->Size = System::Drawing::Size(30, 19);
this->textBox20->TabIndex = 33;
//
// label4
//
this->label4->AutoSize = true;
this->label4->Location = System::Drawing::Point(760, 304);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(115, 12);
this->label4->TabIndex = 34;
this->label4->Text = L"生れた日とリズムが同じ";
//
// textBox21
//
this->textBox21->Location = System::Drawing::Point(680, 422);
this->textBox21->Margin = System::Windows::Forms::Padding(2);
this->textBox21->Name = L"textBox21";
this->textBox21->Size = System::Drawing::Size(207, 19);
this->textBox21->TabIndex = 35;
//
// button8
//
this->button8->Location = System::Drawing::Point(677, 104);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(43, 24);
this->button8->TabIndex = 36;
this->button8->Text = L"前月";
this->button8->UseVisualStyleBackColor = true;
this->button8->Click += gcnew System::EventHandler(this, &Form1::button8_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(922, 480);
this->Controls->Add(this->button8);
this->Controls->Add(this->textBox21);
this->Controls->Add(this->label4);
this->Controls->Add(this->textBox20);
this->Controls->Add(this->textBox19);
this->Controls->Add(this->textBox18);
this->Controls->Add(this->button7);
this->Controls->Add(this->button6);
this->Controls->Add(this->button5);
this->Controls->Add(this->button4);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->label7);
this->Controls->Add(this->textBox17);
this->Controls->Add(this->label6);
this->Controls->Add(this->textBox16);
this->Controls->Add(this->textBox15);
this->Controls->Add(this->textBox14);
this->Controls->Add(this->textBox13);
this->Controls->Add(this->textBox12);
this->Controls->Add(this->textBox11);
this->Controls->Add(this->label5);
this->Controls->Add(this->textBox10);
this->Controls->Add(this->textBox9);
this->Controls->Add(this->textBox8);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->textBox7);
this->Controls->Add(this->textBox6);
this->Controls->Add(this->textBox5);
this->Controls->Add(this->textBox4);
this->Controls->Add(this->textBox3);
this->Controls->Add(this->textBox2);
this->Controls->Add(this->textBox1);
this->Controls->Add(this->button1);
this->Margin = System::Windows::Forms::Padding(2);
this->Name = L"Form1";
this->Text = L"プログラムの練習 バイオリズムの考察";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);
this->ResumeLayout(false);
this->PerformLayout();

}
#pragma endregion
private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
Graphics^ gr=e->Graphics;
System::Drawing::Font^ font1=gcnew System::Drawing::Font("MS ゴシック",11);
System::Drawing::Font^ font2=gcnew System::Drawing::Font("MS ゴシック",10);

gr->DrawString("赤-身体",font1,Brushes::Red,10,1);
gr->DrawString("緑-感情",font1,Brushes::Green,110,1);
gr->DrawString("青-知性",font1,Brushes::Blue,210,1);

/*gr->DrawString("生まれた年の  日数=",font1,Brushes::Black,10,320);
gr->DrawString(day1.ToString(),font1,Brushes::Black,320,320);

gr->DrawString("生翌年から前年の日数=",font1,Brushes::Black,10,340);
gr->DrawString(day2.ToString(),font1,Brushes::Black,320,340);

gr->DrawString("測定年の 日数=",font1,Brushes::Black,10,360);
gr->DrawString(day3.ToString(),font1,Brushes::Black,320,360);*/

gr->DrawString("生きている 日数=",font1,Brushes::Black,10,320);
gr->DrawString(day.ToString(),font1,Brushes::Black,200,320);
double t;
int x1,tt=1,td;
int xx=15,yy=200;
int y1,y2,y3;
td=eDay;
for(t=1;t<=31;t=t+0.05){
x1=(t-1)*20;
y1=sin(3.141592654*((day + t-1)/23)*360/180)*100;
gr->FillRectangle(Brushes::Red,x1+xx,yy-y1,1,1);

y2=sin(3.141592654*((day + t-1)/28)*360/180)*100;
gr->FillRectangle(Brushes::Green,x1+xx,yy-y2,1,1);

y3=sin(3.141592654*((day + t-1)/33)*360/180)*100;
gr->FillRectangle(Brushes::Blue,x1+xx,yy-y3,1,1);
td=(x1/20)+eDay;
if (td>=gMonth) td=td-gMonth;
tt++;
if(tt==100|| t==1){
gr->DrawString(td.ToString(),font2,Brushes::Black,x1+xx,yy+10);
tt=0;
}
}
gr->DrawLine(Pens::Black, xx,yy,xx+31*20,yy);
gr->DrawLine(Pens::Black, xx,yy-100,xx,yy+100);

}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
calc();
}

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

textBox1->Text="1945";
textBox2->Text="8";
textBox3->Text="6";
time_t current;
struct tm *local;
time(&current); /* 現在の時刻を取得 */
local = localtime(&current); /* 地方時の構造体に変換 */
textBox4->Text=(local->tm_year + 1900).ToString();
textBox5->Text=(local->tm_mon + 1).ToString() ;
textBox6->Text=(local->tm_mday).ToString() ;
textBox7->Text=(local->tm_year + 1900).ToString();
textBox8->Text=(local->tm_mon + 1).ToString() ;
textBox9->Text=(local->tm_mday).ToString() ;
textBox18->Text=(local->tm_year + 1900).ToString();
textBox19->Text=(local->tm_mon + 1).ToString() ;
textBox20->Text=(local->tm_mday).ToString() ;
youbi1=int(local->tm_wday) ;

eYear=int::Parse(textBox4->Text);
eMonth=int::Parse(textBox5->Text);
eDay=int::Parse(textBox6->Text);

tYear=eYear;
tMonth=eMonth;
tDay=eDay;
day=0;

}
//フリーゲルの公式
private: int freegel(int Y,int M,int D){
//int の範囲 -2147483648〜2147483647
//1-2000年 オーバーしない 365*2000=730000
//フリーゲルの公式
//day1=int(365.25 * Y1) + int(Y1 / 400) - int(Y1 / 100) + int(30.59 * (M1 - 2)) + D1 - 678912;
//day1=( 365 * (Y1 - 1))+((Y1 >> 2) -( Y1/100) + ((Y1/100) >> 2))+ ((M1 * 979 - 1033) >> 5)+D1-1;
//1年1月1日から M月1日までの日数
int kday;
kday=( 365 * (Y - 1))+((Y >> 2) -( Y/100) + ((Y/100) >> 2))+ ((M * 979 - 1033) >> 5)+D-1;
return kday;
}
private: int urumonth( int y,int m ) //平年および閏年の各月数
{
int h;
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0) {
h = 29;
} else {
h = 28;
}
int mm[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
mm[1]=h;
return mm[m];

}
private: int uryear(int y ) //閏年の判定 0 以外 うるう年
{
return (0 == (y % 400)) || ((0 != (y % 100)) && (0 == (y % 4)));

}

private: Void calc(){
int youbi2;
/*if(textBox1->Text=="")textBox1->Text=="1900";
if(textBox2->Text=="")textBox2->Text=="1";
if(textBox3->Text=="")textBox3->Text=="1";
if(textBox4->Text=="")textBox4->Text=="2000";
if(textBox5->Text=="")textBox5->Text=="1";
if(textBox6->Text=="")textBox6->Text=="1";*/

fYear=int::Parse(textBox1->Text);
fMonth=int::Parse(textBox2->Text);
fDay=int::Parse(textBox3->Text);
eYear=int::Parse(textBox4->Text);
eMonth=int::Parse(textBox5->Text);
eDay=int::Parse(textBox6->Text);
int day1,day2,day3,day4,day5;
// 生まれからの日数を出す

int Y1=fYear;
int M1=fMonth;
int D1=fDay;
if(M1==1||M1==2){
M1+=12;Y1--;
}
//フリーゲルの公式へ
day1=freegel(Y1,M1,D1);

int Y2=eYear;
int M2=eMonth;
int D2=eDay;
if(M2==1||M2==2){
M2+=12;Y2--;
}
//フリーゲルの公式へ
day2=freegel(Y2,M2,D2);
int Y3=tYear;
int M3=tMonth;
int D3=tDay;
if(M3==1||M3==2){
M3+=12;Y3--;
}
//フリーゲルの公式へ
day3=freegel(Y3,M3,D3);
day=day2-day1+1;
if (day<23*28*33);
if (day<1) textBox11->Text="生まれていません";
else textBox11->Text=day.ToString();
//再線画
Invalidate();
//曜日の表示
array<String^ >^ wday = gcnew array<String^> {"日", "月", "火", "水", "木", "金", "土"};
textBox10->Text=wday[youbi1]; // 日曜からの曜日 : 0 ... 6
int amari,motome;
day4=day3-day1+1;
amari=day4 % 7;
motome=youbi1 - amari+1 ;
if( motome< 0 ) motome=7+motome;
if(motome<0 || motome>6) motome=0;
textBox12->Text=wday[motome]; // 日曜からの曜日 : 0 ... 6
textBox13->Text=amari.ToString(); // 日曜からの曜日 : 0 ... 6
//西暦y年m月d日の曜日を求める。
//w = (5y/4-y/100+y/400+(26m+16)/10+d)%7 曜日を求める(Zellerの公式)】
motome = (((5*Y1)/4)-(Y1/100)+(Y1/400)+(26*M1+16)/10+D1)%7;
textBox14->Text=wday[motome]; // 日曜からの曜日 : 0 ... 6
//==========================
//最悪の日を出す
day5=day1+23*28*33;
int Y4,M4,D4,Y5,M5,D5,loopE=0;
Y5=Y1;
do {
Y4=Y5;
for(M5=1;M5<13;M5++){
M4=M5;
if(M4==1||M4==2){
M4+=12;Y4--;
}
for(D5=1;D5<32;D5++){
//フリーゲルの公式へ
day6=freegel(Y4,M4,D5);

if(day5==day6){ loopE=1;
Y6=Y5-2;
M6=M5;
D6=D5;
}
if(Y5>Y1+100) loopE=1;
}
}
Y5++;
} while (loopE==0);
textBox15->Text=Y6.ToString();
textBox16->Text=M6.ToString();
textBox17->Text=D6.ToString();
//==========================
}

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
textBox4->Text=Y6.ToString();
textBox5->Text=M6.ToString() ;
textBox6->Text="1";
calc();

}
private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) {
time_t current;
struct tm *local;
time(&current); /* 現在の時刻を取得 */
local = localtime(&current); /* 地方時の構造体に変換 */
textBox4->Text=(local->tm_year + 1900).ToString();
textBox5->Text=(local->tm_mon + 1).ToString() ;
textBox6->Text=(local->tm_mday).ToString() ;
calc();

}
private: System::Void button4_Click(System::Object^ sender, System::EventArgs^ e) {

int yYear=int::Parse(textBox4->Text);
int yMonth=int::Parse(textBox5->Text);
yMonth++;
if(yMonth>12) {yMonth=1;
yYear++;
}
textBox4->Text=yYear.ToString();
textBox5->Text=yMonth.ToString() ;
textBox6->Text="1";
calc();

}
private: Void fukitsu(){
int yYear=int::Parse(textBox4->Text);
int yMonth=int::Parse(textBox5->Text);
textBox6->Text="1";
int yDay=int::Parse(textBox6->Text);

calc();
float t;
int tt=-1,tt1,tt2;
int yy,mm;
double y1,y2,y3;
for(yy=yYear;yy<yYear+1;yy++){
for(mm=yMonth;mm<13;mm++){
int month;
month=urumonth( yYear,yMonth);
for(t=1;t<=month;t=t+0.05){
y1=sin(3.141592654*((day + t-1)/23)*360/180);
y2=sin(3.141592654*((day + t-1)/28)*360/180);
y3=sin(3.141592654*((day + t-1)/33)*360/180);
if((y1<0.15 && y1>-0.15) && (y2<0.15 && y2>-0.15)) tt=(int)t;
if((y1<0.15 && y1>-0.15) && (y3<0.15 && y3>-0.15)) tt=(int)t;
if((y2<0.15 && y2>-0.15) && (y3<0.15 && y3>-0.15)) tt=(int)t;
}//for t
if(tt>-1){
tt1=tt+yDay;
if (tt1>27) ;
textBox18->Text=yy.ToString();
textBox19->Text=mm.ToString();
textBox20->Text=tt.ToString();
textBox21->Text=t.ToString();

break;
}
if(tt>-1) break;
} //for mm
if(tt>-1) break;

}//for yy
if(tt==-1) textBox21->Text="この月は特に問題がありません";
else textBox21->Text="上記の日は特にご注意ください";

}
private: System::Void button5_Click(System::Object^ sender, System::EventArgs^ e) {
time_t current;
struct tm *local;
time(&current); /* 現在の時刻を取得 */
local = localtime(&current); /* 地方時の構造体に変換 */
textBox4->Text=(local->tm_year + 1900).ToString();
textBox5->Text=(local->tm_mon + 1).ToString();
textBox6->Text=(local->tm_mday).ToString();
textBox18->Text=(local->tm_year + 1900).ToString();
textBox19->Text=(local->tm_mon + 1).ToString();
textBox20->Text=(local->tm_mday).ToString();

fukitsu();
}
private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {
int yYear=int::Parse(textBox18->Text);
int yMonth=int::Parse(textBox19->Text);
int yDay=int::Parse(textBox20->Text);
yMonth++;
if(yMonth>12) {yMonth=1;
yYear++;
}
textBox4->Text=yYear.ToString();
textBox5->Text=yMonth.ToString();
textBox6->Text=yDay.ToString();;
textBox18->Text=yYear.ToString();
textBox19->Text=yMonth.ToString();
textBox20->Text=yDay.ToString();;
calc();
fukitsu();

}
private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {
int yYear=int::Parse(textBox4->Text);
int yMonth=int::Parse(textBox5->Text);
yMonth--;
if(yMonth<1) {yMonth=12;
yYear--;
}
textBox4->Text=yYear.ToString();
textBox5->Text=yMonth.ToString() ;
textBox6->Text="1";
calc();

}
private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {
int yYear=int::Parse(textBox18->Text);
int yMonth=int::Parse(textBox19->Text);
int yDay=int::Parse(textBox20->Text);
yMonth--;
if(yMonth<1) {yMonth=12;
yYear--;
}
textBox4->Text=yYear.ToString();
textBox5->Text=yMonth.ToString();
textBox6->Text=yDay.ToString();;
textBox18->Text=yYear.ToString();
textBox19->Text=yMonth.ToString();
textBox20->Text=yDay.ToString();;
calc();
fukitsu();

}
};
}

/*
// tm 構造体
struct tm
{
int tm_sec; // 秒 : 0 ... 59
int tm_min; // 分 : 0 ... 59
int tm_hour; // 時 : 0 ...23
int tm_mday; // 日 : 1 ... 31
int tm_mon; // 1月からの月数 : 0 ... 11
int tm_year; // 1900年からの年数
int tm_wday; // 日曜からの曜日 : 0 ... 6
int tm_yday; // 1月1日からの日数 : 0 ... 365
int tm_isdst; // 夏時間は正、そうでなければ0、不明は負
}; */
/*
【曜日を求める(Zellerの公式)】
西暦Y年M月D日の曜日を求める。
W = (5*Y/4-Y/100+Y/400+(26*M+16)/10+D)%7
*/

実行 プログラムダウンロード
NetFramework が必要です 

NetFreamworks v3.5 ダウンロード

bior-v4.exe

ソース bior-v4.rar

 
動画が旨くご覧いただけない場合は最新のFlash Playerをインストールしてください
web ブラウザがインターネットエクスプローラ6(IE6)以下の場合メニューが崩れてしまうことがあります。
インターネットエクスプローラ7、Sleipnir、Mozilla Firefoxをご使用ください。