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

pc2

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

アルゴリズム
電子回路

 






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

 

ロボット・DOSV掲示板兼Blog

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

roboto

Topに戻る

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

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


工作


集団練習メニュー


しつけ 訓練コラム




最後にララについて

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

Laraララの
ブログ

犬のしつけと訓練
掲示板


掲示板の利用規則

 

 

 

 

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

 

Visual Studio 2008 Express Edition でトランプゲームを作ろう
8日目 VBAのリストをC++に変換してみよう

2日目の学習

から再スタート
cpp to basic1

復習

この�.襦璽船鵑肇椒織鵤院´△瞭睛討�必要です。


//��

static int card[55];
static int hai[12];
static int keta[12];
static int yaku[12];
static int start_flag=0;
static int hoji1=0;
static int hoji2=0;
static int hoji3=0;
static int hoji4=0;
static int hoji5=0;
static int tokuten=0;

void DispHai( int nohai,int xx){
Graphics^ gr=this->CreateGraphics();
int X0=10,Y0=1;
String^ filename;
filename="c:\\card\\1_sp.gif";
if(nohai==0 ) filename="c:\\card\\0_r1.gif" ;
//Pen^ pen1=gcnew Pen(col);
if(nohai>0 && nohai<14) filename="c:\\card\\"+nohai+"_sp.gif" ;
if(nohai>100 && nohai<114 ){nohai=nohai-100;
filename="c:\\card\\"+nohai+"_cl.gif" ;}
if(nohai>200 && nohai<214 ){nohai=nohai-200;
filename="c:\\card\\"+nohai+"_di.gif" ;}
if(nohai>300 && nohai<314){nohai=nohai-300;
filename="c:\\card\\"+nohai+"_he.gif" ;}
//原画像を左上に描画する
if(xx==1){
Bitmap^ bmap1; //bmap1の確保
bmap1=gcnew Bitmap(filename);
gr->DrawImage(bmap1,X0,Y0);
}
if(xx==2){
Bitmap^ bmap2; //bmap2の確保
bmap2=gcnew Bitmap(filename);
gr->DrawImage(bmap2,X0+100,Y0);
}
if(xx==3){
Bitmap^ bmap3; //bmap3の確保
bmap3=gcnew Bitmap(filename);
gr->DrawImage(bmap3,X0+200,Y0);
}
if(xx==4){
Bitmap^ bmap4; //bmap4の確保
bmap4=gcnew Bitmap(filename);
gr->DrawImage(bmap4,X0+300,Y0);
}
if(xx==5){
Bitmap^ bmap5; //bmap5の確保
bmap5=gcnew Bitmap(filename);
gr->DrawImage(bmap5,X0+400,Y0);
}
}


//��
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if(start_flag ==0){ //一度通過したら度目を禁止する
int amax,xrand,nohai;
int xx,yy,y;
char buf[80];
Graphics^ gr=this->CreateGraphics();
String^ string1;
Brush^ brush=gcnew SolidBrush(Color::Black);
System::Drawing::Font^ font=gcnew System::Drawing::Font("MS ゴシック",10);
Random^ rand=gcnew Random(); //で乱数randを生成しておき、
//2) 以上int amax未満の乱数を発生したい場合には、
amax=52;
for(xx=1;xx<54;xx++) card[xx]=0;
yy=1;
while(yy<20){
xrand=rand->Next(amax)+1;
int flag=0;
for(xx=1;xx<53;xx++) {if(card[xx]==xrand) flag=1;}
if(flag==0){ card[yy]=xrand;
//文字で確認
sprintf_s(buf,80," %3d ",xrand);
string1=gcnew String(buf);
gr->DrawString(string1,font,brush,(float)16*yy,(float)300);
//文字で確認終了
yy++;}
}
for(y=1;y<53;y++){
if( card[y] > 13 && card[y] <= 26) card[y] = card[y] + 100 - 13;
if( card[y] > 26 && card[y] <= 39) card[y] = card[y] + 200 - 26;
if( card[y] > 39 && card[y] <= 52) card[y] = card[y] + 300 - 39;
} //end for y
for(xx=1;xx<6;xx++){
hai[xx]=card[xx];
}
for(xx=1;xx<6;xx++){
nohai=hai[xx];
DispHai(nohai,xx);
}

//次のように変更 青を赤に
for(xx=1;xx<6;xx++){
DispHai(0,xx);
}

hoji1=0;
hoji2=0;
hoji3=0;
hoji4=0;
hoji5=0;
start_flag=1; //一度通過したら度目を禁止するフラッグ
}//end if start_flag=1;一度通過したら度目を禁止する
}


ボタン2をクリックして
次のようにカードの表示をするようにします
basicの内容【緑】を次のように変更する【赤】
緑の部分から同じ所を切り取る

basic c++


Private Sub card_hai()
If z = 1 Then Image59.Picture = Image1.Picture
If z = 2 Then Image59.Picture = Image2.Picture
If z = 3 Then Image59.Picture = Image3.Picture
If z = 4 Then Image59.Picture = Image4.Picture
If z = 5 Then Image59.Picture = Image5.Picture
If z = 6 Then Image59.Picture = Image6.Picture
If z = 7 Then Image59.Picture = Image7.Picture
If z = 8 Then Image59.Picture = Image8.Picture
If z = 9 Then Image59.Picture = Image9.Picture
If z = 10 Then Image59.Picture = Image10.Picture
If z = 11 Then Image59.Picture = Image11.Picture
If z = 12 Then Image59.Picture = Image12.Picture
If z = 13 Then Image59.Picture = Image13.Picture
If z = 101 Then Image59.Picture = Image14.Picture
If z = 102 Then Image59.Picture = Image15.Picture
If z = 103 Then Image59.Picture = Image16.Picture
If z = 104 Then Image59.Picture = Image17.Picture
If z = 105 Then Image59.Picture = Image18.Picture
If z = 106 Then Image59.Picture = Image19.Picture
If z = 107 Then Image59.Picture = Image20.Picture
If z = 108 Then Image59.Picture = Image21.Picture
If z = 109 Then Image59.Picture = Image22.Picture
If z = 110 Then Image59.Picture = Image23.Picture
If z = 111 Then Image59.Picture = Image24.Picture
If z = 112 Then Image59.Picture = Image25.Picture
If z = 113 Then Image59.Picture = Image26.Picture
If z = 201 Then Image59.Picture = Image27.Picture
If z = 202 Then Image59.Picture = Image28.Picture
If z = 203 Then Image59.Picture = Image29.Picture
If z = 204 Then Image59.Picture = Image30.Picture
If z = 205 Then Image59.Picture = Image31.Picture
If z = 206 Then Image59.Picture = Image32.Picture
If z = 207 Then Image59.Picture = Image33.Picture
If z = 208 Then Image59.Picture = Image34.Picture
If z = 209 Then Image59.Picture = Image35.Picture
If z = 210 Then Image59.Picture = Image36.Picture
If z = 211 Then Image59.Picture = Image37.Picture
If z = 212 Then Image59.Picture = Image38.Picture
If z = 213 Then Image59.Picture = Image39.Picture
If z = 301 Then Image59.Picture = Image40.Picture
If z = 302 Then Image59.Picture = Image41.Picture
If z = 303 Then Image59.Picture = Image42.Picture
If z = 304 Then Image59.Picture = Image43.Picture
If z = 305 Then Image59.Picture = Image44.Picture
If z = 306 Then Image59.Picture = Image45.Picture
If z = 307 Then Image59.Picture = Image46.Picture
If z = 308 Then Image59.Picture = Image47.Picture
If z = 309 Then Image59.Picture = Image48.Picture
If z = 310 Then Image59.Picture = Image49.Picture
If z = 311 Then Image59.Picture = Image50.Picture
If z = 312 Then Image59.Picture = Image51.Picture
If z = 313 Then Image59.Picture = Image52.Picture

 

End Sub

Private Sub disp()
z = card(1)
Call card_hai
Image54.Picture = Image59.Picture
z = card(2)
Call card_hai
Image55.Picture = Image59.Picture
z = card(3)
Call card_hai
Image56.Picture = Image59.Picture
z = card(4)
Call card_hai
Image57.Picture = Image59.Picture
z = card(5)
Call card_hai
Image58.Picture = Image59.Picture

End Sub

Private Sub CommandButton2_Click()
Call disp

End Sub

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
int xx;
for(xx=1;xx<6;xx++){
DispHai(card[xx],xx);
}
}

 

 

参考


void DispHai( int nohai,int xx){

Graphics^ gr=this->CreateGraphics();
int X0=10,Y0=1;
String^ filename;
filename="c:\\card\\1_sp.gif";
if(nohai==0 ) filename="c:\\card\\0_r1.gif" ;
//Pen^ pen1=gcnew Pen(col);
if(nohai>0 && nohai<14) filename="c:\\card\\"+nohai+"_sp.gif" ;
if(nohai>100 && nohai<114 ){nohai=nohai-100;
filename="c:\\card\\"+nohai+"_cl.gif" ;}
if(nohai>200 && nohai<214 ){nohai=nohai-200;
filename="c:\\card\\"+nohai+"_di.gif" ;}

if(nohai>300 && nohai<314){nohai=nohai-300;
filename="c:\\card\\"+nohai+"_he.gif" ;}
//原画像を左上に描画する
if(xx==1){
Bitmap^ bmap1; //bmap1の確保
bmap1=gcnew Bitmap(filename);
gr->DrawImage(bmap1,X0,Y0);
}
if(xx==2){
Bitmap^ bmap2; //bmap2の確保
bmap2=gcnew Bitmap(filename);
gr->DrawImage(bmap2,X0+100,Y0);
}
if(xx==3){
Bitmap^ bmap3; //bmap3の確保
bmap3=gcnew Bitmap(filename);
gr->DrawImage(bmap3,X0+200,Y0);
}
if(xx==4){
Bitmap^ bmap4; //bmap4の確保
bmap4=gcnew Bitmap(filename);
gr->DrawImage(bmap4,X0+300,Y0);
}
if(xx==5){
Bitmap^ bmap5; //bmap5の確保
bmap5=gcnew Bitmap(filename);
gr->DrawImage(bmap5,X0+400,Y0);
}
}


private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
Graphics^ gr=e->Graphics;
}
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
if(start_flag ==0){ //一度通過したら度目を禁止する
int amax,xrand,nohai;
int xx,yy,y;
char buf[80];
Graphics^ gr=this->CreateGraphics();
String^ string1;
Brush^ brush=gcnew SolidBrush(Color::Black);
System::Drawing::Font^ font=gcnew System::Drawing::Font("MS ゴシック",10);

Random^ rand=gcnew Random(); //で乱数randを生成しておき、
//2) 以上int amax未満の乱数を発生したい場合には、

amax=52;
for(xx=1;xx<54;xx++) card[xx]=0;
yy=1;
while(yy<20){
xrand=rand->Next(amax)+1;
int flag=0;
for(xx=1;xx<53;xx++) {if(card[xx]==xrand) flag=1;}
if(flag==0){ card[yy]=xrand;
//文字で確認
sprintf_s(buf,80," %3d ",xrand);
string1=gcnew String(buf);
gr->DrawString(string1,font,brush,(float)16*yy,(float)300);
//文字で確認終了
yy++;}
}
for(y=1;y<53;y++){
if( card[y] > 13 && card[y] <= 26) card[y] = card[y] + 100 - 13;
if( card[y] > 26 && card[y] <= 39) card[y] = card[y] + 200 - 26;
if( card[y] > 39 && card[y] <= 52) card[y] = card[y] + 300 - 39;
} //end for y

for(xx=1;xx<6;xx++){
DispHai(0,xx);
}
hoji1=0;
hoji2=0;
hoji3=0;
hoji4=0;
hoji5=0;

start_flag=1; //一度通過したら度目を禁止するフラッグ
}//end if start_flag=1;一度通過したら度目を禁止する

 

}
private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) {
int xx;
for(xx=1;xx<6;xx++){
DispHai(card[xx],xx);
}


実際のsample sample4.exe sample4.zip

 

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