標題:
2024/11/29 課堂重點(昀杰)
[打印本頁]
作者:
郭竑志
時間:
2024-11-29 16:57
標題:
2024/11/29 課堂重點(昀杰)
本帖最後由 郭竑志 於 2024-12-13 16:56 編輯
[作業檢查]
陣列 (七)
陣列 (八)
陣列 (九)
產生介於指定範圍內的隨機亂數 (二)
[課程重點]
產生介於指定範圍內的隨機亂數 (四)
猜拳遊戲 (一)
猜拳遊戲 (二)
跑馬燈 (一) - _sleep() 函式
抽籤程式 (一)
許功蓋
Alt 特殊字元輸入對照表
賽馬程式 (一)
賽馬程式 (二)
賽馬程式 (三)
賽馬程式 (四)
賽馬程式 (五)
賽馬程式 (六)
[今日作業]
猜拳遊戲 (三)
跑馬燈 (二)
賽馬程式 (七)
作者:
陳昀杰
時間:
2024-11-29 19:05
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a[5][4]= {{0,9,8,0},{0,9,8,0},{0,9,8,0},{0,9,8,0},{0,9,8,0}};
int g[5][6]= {{4,5,4,6,6,6},{4,5,4,6,6,6},{4,5,4,6,6,6},{4,5,4,6,6,6},{4,5,4,6,6,6}};
for(int i=0; i<5; i++)
{
for(int j=0; j<4; j++)
{
cout<<a[i][j];
}
for(int k=0; k<6; k++)
{
cout<<g[i][k];
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2024-11-29 19:09
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
for(int a=1;a<=50;a++){
cout<<rand()%15-7<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2024-11-29 19:18
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
string a[3]={"剪刀!","石頭!","布!"};
cout<<a[player-1];
cout<<"電腦出";
cout<<a[computer-1];
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2024-12-2 20:44
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{
srand(time(NULL));
int player,computer;
cout<<"請出拳! (1)剪刀(2)石頭(3)布 ";
cin>>player;
computer=rand()%3+1;
cout<<"你出";
string a[3]= {"剪刀!","石頭!","布!"};
cout<<a[player-1];
cout<<"電腦出";
cout<<a[computer-1];
if(player==computer)
cout<<"same";
else if(player==3 && computer==2)
cout<<" you win";
else if(player==3 && computer==2)
cout<<"you win";
else if(player==2 && computer==1)
cout<<"you win";
else if(player==1 && computer==3)
cout<<"you win";
else
cout<<"you lose";
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2024-12-2 21:02
#include<iostream>
#include<cstdlib>
#include<ctime>
#include <windows.h>
using namespace std;
int main()
{
int s[10][10]= {
{1,0,0,0,0,0,0,0,0,0},
{0,1,0,0,0,0,0,0,0,0},
{0,0,1,0,0,0,0,0,0,0},
{0,0,0,1,0,0,0,0,0,0},
{0,0,0,0,1,0,0,0,0,0},
{0,0,0,0,0,1,0,0,0,0},
{0,0,0,0,0,0,1,0,0,0},
{0,0,0,0,0,0,0,1,0,0},
{0,0,0,0,0,0,0,0,1,0},
{0,0,0,0,0,0,0,0,0,1},
};
for(int r=0; r<10; r++)
{_sleep(50);
system("cls");
cout<<" 載入中"<<(r+1)*10<<"% ";
for(int h=0; h<10; h++)
{
cout<<s[r][h];
_sleep(50);
}
cout<<endl;
}
system("pause");
return 0;
}
複製代碼
作者:
陳昀杰
時間:
2024-12-13 18:58
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
int main()
{ int d=1;
int m=0;
re:
system("cls");
int s[]={0,0,0,0};
srand(time(NULL));
cout<<"「好事成雙」賽馬場,第"<<d<<"回"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
cout<<"◆"<<endl;
cout<<"★"<<endl;
cout<<"▲"<<endl;
cout<<"●"<<endl;
cout<<"balance"<<m<<"dollars"<<endl;
cout<<"1.buy"<<endl;
cin>>m;
d=d+1;
system("pause");
while(true)
{
system("cls");
int r=rand()%4; //0~3
s[r]++;
cout<<"比賽進行中"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"●"<<endl;
if(s[r]==73)
break;
_sleep(0.001);
}
system("cls");
cout<<"比賽結束"<<endl;
cout<<"-------------------------------------------------------------------------| 終點"<<endl;
for(int i=0; i<=s[0]; i++)
cout<<" ";
cout<<"◆"<<endl;
for(int i=0; i<=s[1]; i++)
cout<<" ";
cout<<"★"<<endl;
for(int i=0; i<=s[2]; i++)
cout<<" ";
cout<<"▲"<<endl;
for(int i=0; i<=s[3]; i++)
cout<<" ";
cout<<"●"<<endl;
system("pause");
goto re;
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://www.istak.org.tw/seed/)
Powered by Discuz! 7.2